Hi all,

Now I am able to call jQuery functions from other blocks.

Please help me in solving this one also.

I have a form with select option. It will be populated dynamically after
every ajax request.

In form, I have a select tag with no options.

<select id='users'>
</select>

After getting a content from ajax, I am preparing all the available options,
and placing that content in select tag.

var opts = "<option value='1'>Murali</option><
>
> option value='2'>Krishna</option>";
> $("#users").html(opts);



> But it is not showing any options in the select tag.
>


Thanks,

Murali.

On Mon, Nov 9, 2009 at 6:24 PM, Dhruva Sagar <dhruva.sa...@gmail.com> wrote:

> The function by itself will not be available within other blocks, since the
> function is in local scope.
> You should attach the function to the jQuery object instead for later use
> using the following syntax :
>
> (function($) {
>
>   $.function_name = function test() {
>     alert('in function');
>   }
> })(jQuery);
>
> Then later in other jQuery blocks (although you will have to ensure that
> your previously defined block has been already included) you can call your
> function simply by using $.function_name();
>
> Thanks & Regards,
> Dhruva Sagar.
>
>
>
>
>
> On Mon, Nov 9, 2009 at 4:27 PM, Murali Krishna B <
> muralikrishna.vi...@gmail.com> wrote:
>
>> Hi all,
>>
>> I am creating a function using jQuery in application.js file.
>>
>> (function($) {
>>
>>   function test() {
>>     alert('in function');
>>   }
>> })(jQuery);
>>
>> When I am trying to call this function from outside (not in this jQuery
>> block), I am getting an error saying that function is not defined.
>> I am including this file, also I am calling this function from a jQuery
>> block. Still I am getting this error.
>>
>> How to call that function?
>>
>> --------------------------------------------------------
>>
>> Also, I am facing another issue. I have a form with select option. It will
>> be populated dynamically after every ajax request.
>>
>> In form, I have a select tag with no options.
>>
>> <select id='users'>
>> </select>
>>
>> After getting a content from ajax, I am preparing all the available
>> options, and placing that content in select tag.
>>
>> var opts = "<option value='1'>Murali</option><option
>> value='2'>Krishna</option>";
>> $("#users").html(opts);
>>
>> But it is not showing any options in the select tag.
>>
>> Pls help me,
>>
>> --
>> Thanks & Regards,
>>
>> Murali Krishna.B
>>
>
>


-- 
Thanks & Regards,

Murali Krishna.B

Reply via email to