Skip to content

Commit

Permalink
update onchange triggering to work with react
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Best committed Apr 24, 2017
1 parent 5a49e06 commit 24832c9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/js/jquery.emojiarea.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,8 @@
};

EmojiArea_WYSIWYG.prototype.onChange = function(e) {
this.$textarea.val(this.val()).trigger('change');
var event = new CustomEvent('input', { bubbles: true });
this.$textarea.val(this.val())[0].dispatchEvent(event);
};

EmojiArea_WYSIWYG.prototype.insert = function(emoji) {
Expand Down
17 changes: 15 additions & 2 deletions lib/js/util.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';

function cancelEvent (event) {
event = event || window.event;
if (event) {
Expand Down Expand Up @@ -205,8 +205,21 @@ function getGuid() {
set: storageSetValue,
remove: storageRemoveValue
};
})(this);

// Pollyfill for IE 9 support of CustomEvent
(function () {

})(this);
if ( typeof window.CustomEvent === "function" ) return false;

function CustomEvent ( event, params ) {
params = params || { bubbles: false, cancelable: false, detail: undefined };
var evt = document.createEvent( 'CustomEvent' );
evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail );
return evt;
}

CustomEvent.prototype = window.Event.prototype;

window.CustomEvent = CustomEvent;
})();

0 comments on commit 24832c9

Please sign in to comment.