Skip to content

Commit

Permalink
support IE8 with triggerNative
Browse files Browse the repository at this point in the history
  • Loading branch information
caseyjhol committed May 29, 2015
1 parent 01f3bc2 commit 8cade79
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions js/bootstrap-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,31 @@
}

$.fn.triggerNative = function (eventName) {
var event;
var el = this[0],
event;

if (el.dispatchEvent) {
if (typeof Event === 'function') {
// For modern browsers
event = new Event(eventName, {
bubbles: true
});
} else {
// For IE since it doesn't support Event constructor
event = document.createEvent('Event');
event.initEvent(eventName, true, false);
}

if (typeof Event === 'function') {
// For modern browsers
event = new Event(eventName, {
bubbles: true
});
el.dispatchEvent(event);
} else {
// For IE since it doesn't support Event constructor
event = document.createEvent('Event');
event.initEvent(eventName, true, false);
}
if (el.fireEvent) {
event = document.createEventObject();
event.eventType = eventName;
el.fireEvent('on' + eventName, event);
}

this[0].dispatchEvent(event);
this.trigger(eventName);
}
};
//</editor-fold>

Expand Down

0 comments on commit 8cade79

Please sign in to comment.