gator
gator copied to clipboard
legacy IE bug with change events
For some reason change events are not firing in IE8 and below:
Gator(document).on('change', '#someid', function(e) {
//do something -
});
click works tho.
Thanks for the ticket. It seems the change event does not bubble in old IE
http://stackoverflow.com/questions/265074/does-the-onchange-event-propagate http://stackoverflow.com/questions/1637503/jquery-change-event-on-select-not-firing-in-ie
I will see if this is something I can handle in gator
In the mean time you could try binding directly to the element
Gator(document.getElementById('someid')).on('change', function() {
// do something
});
So I was just looking into this. Binding directly to the element is definitely the best solution for now. I will try to get this added to Gator, but legacy IE support is not super high priority since this library was really designed with modern browsers in mind.
In order to implement I would have to change the way some things work in Gator itself.
For reference
I was just looking at the jQuery source to see how they handle this and it looks like they do something where they listen for propertychange
for checkboxes and radio inputs and simulate a change event on the parent.
For selects, inputs, and other form elements they attach a click event and then once the click bubbles up they attach a change event to the target element the click came from (so it is lazy loaded).
Once the change event is attached to the element it does not attach it again on subsequent clicks. Once the change fires on the target it simulates a change event.
According to http://caniuse.com/matchesselector it doesn't work in oldIE, and in the code, the polyfill Gator.matchesSelector
is an empty function...
@tomasdev there is a legacy.js file that adds some of the old ie functionality, it is specifically the change event that doesn't work:
https://github.com/ccampbell/gator/blob/master/plugins/gator-legacy.js