3

I excavated this thread: JQuery live or something similar with .change()?

I have exactly the same problem as the person in that thread. I need to call change() on elements appended() in DOM.

I had success in using .live() but for clicks. Now I need to do the same things for the change in drop down list selection.

Ideally I don't want to use any plugins, as suggested in the topic.

Does anyone has any ideas how to solve the problem?

Community
  • 1
  • 1
Eleeist
  • 6,891
  • 10
  • 50
  • 77

3 Answers3

3

As of jQuery 1.7, $.live() is deprecated. You should use the new $.on() method:

$("form").on("change", "select", function(){
  alert ( this.value );
});

Demo: http://jsbin.com/ahikov/edit#javascript,html

Sampson
  • 265,109
  • 74
  • 539
  • 565
1

Use .on() with the "delegated" syntax.

$(function ()
{
    $(document).on('change', 'select', function ()
    {
        // your event handling code here
    });
});
Matt Ball
  • 354,903
  • 100
  • 647
  • 710
0

If you have the latest version of jQuery, I recommend you to use the "on" method instead of "click" "change" "live" etc.... try to attach your event from document:

    $(document).on('change', '.yourItem', function (e) {
        //Your code
    });
marcos.borunda
  • 1,486
  • 1
  • 17
  • 34