Alex Rivera | Logout

jQuery live, change in not working in IE6, IE7

Asked 2009-09-20T19:12:00.003
16

The code below works as expected in FF but not in IEs...

$(document).ready(function() {

    $('div.facet_dropdown select').live('change', function() {
        var changed_facet = $(this).attr('id');
        var facets = $('select', $(this).closest('form'));
        var args = window.location.href.split('?')[0] + '?ajax=1';
        var clear = false;
        for(var i = 0; i < facets.length; i++) {
            var ob = $(facets[i]);
            var val = ob.val();
            if(clear) {
                val = '';
            }
            args += '&' + ob.attr('id') + '=' + val;
            if(ob.attr('id') == changed_facet) {
                clear = true;
            }
        }

        $.getJSON(args, function(json) {
            for(widget_id in json) {
                var sel = '#field-' + widget_id + ' div.widget';
                $(sel).html(json[widget_id]);
            }
        });

    });

});
Edit
Report

3 Answers

24

$.live() does not support the change event:

Currently not supported: blur, focus, mouseenter, mouseleave, change, submit http://docs.jquery.com/Events/live

Try using livequery instead?

answered 2009-09-20T19:20:14.887
2

I used -

jQuery('#id').find('select').live("click", function(){
  jQuery(this).change(function(){
    //your code
  });
});
answered 2010-10-07T18:17:04.420
2

Also note that as of jQuery 1.7 you should use "on" instead of delegate or live.

$(selector).live(events, data, handler);                // jQuery 1.3+
$(document).delegate(selector, events, data, handler);  // jQuery 1.4.3+
$(document).on(events, selector, data, handler);        // jQuery 1.7+

Live suffers from a bunch more problems than just the old "no change event" issue: http://api.jquery.com/live/#typefn

answered 2012-06-20T15:02:48.300

Your Answer