JQuery live or something similar with .change ()?

I want to do this: http://docs.jquery.com/Events/live#typefn

Only .live () does not support change events - any ideas for working around?

It is necessary to bind the function to some DOM elements on the fly, but only before the change.

+4
source share
5 answers

Note. jQuery 1.4 now supports the live function for all common events. It did not work with IE8 until recently, but I believe this has been fixed with jQuery 1.4.2. See This jQuery Ticket Allowed: IE8 DOES NOT SUPPORT EVENT CHANGE WHEN USING LIVE

+4
source

The LiveQuery plugin supports all events.

+3
source

Oh, that wasn't so bad, I just wrapped it in a live on click event, and it worked out just fine.

$("#foo").live("click", function(){ $('.fu').change(function(){ blah blah blah }); }); 
+2
source

Well, after Funka comments on my first attempt to answer my own question, I now have this:

 $('.foo').change(function test(){ $(fu).prependTo("#some-div").bind("change", test) $(this).unbind("change",test) }; 

which will associate a function with each element as it is created and untie it from what was created before it. This solves my problem UI-wise, but I'm starting out for beginners, so I'm really open to learning if I miss something again !;)

+2
source

Before .live () appeared in jQuery 1.3, I was very successful with the Arial Flesler listen plugin.

http://flesler.blogspot.com/search/label/jQuery.Listen

I believe that you should do this in the change event with this plugin.

0
source

All Articles