Skip to content

Commit

Permalink
Swaps out all calls to trigger() #3108
Browse files Browse the repository at this point in the history
  • Loading branch information
jlukic committed Nov 1, 2015
1 parent 528a510 commit 2bae116
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
11 changes: 8 additions & 3 deletions src/definitions/modules/checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -502,10 +502,15 @@ $.fn.checkbox = function(parameters) {

trigger: {
change: function() {
module.verbose('Triggering change event from programmatic change');
$input
.trigger('change')
var
events = document.createEvent('HTMLEvents'),
inputElement = $input[0]
;
if(inputElement) {
module.verbose('Triggering native change event');
events.initEvent('change', false, true);
inputElement.dispatchEvent(events);
}
}
},

Expand Down
11 changes: 7 additions & 4 deletions src/definitions/modules/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -1302,11 +1302,14 @@ $.fn.dropdown = function(parameters) {
trigger: {
change: function() {
var
changeEvent = document.createEvent('HTMLEvents')
events = document.createEvent('HTMLEvents'),
inputElement = $input[0]
;
module.verbose('Triggering native change event');
changeEvent.initEvent('change', false, true);
element.dispatchEvent(changeEvent);
if(inputElement) {
module.verbose('Triggering native change event');
events.initEvent('change', false, true);
inputElement.dispatchEvent(events);
}
}
},

Expand Down
18 changes: 15 additions & 3 deletions src/definitions/modules/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,7 @@ $.fn.search = function(parameters) {
// search shortcuts
if(keyCode == keys.escape) {
module.verbose('Escape key pressed, blurring search field');
$prompt
.trigger('blur')
;
module.trigger.blur();
}
if( module.is.visible() ) {
if(keyCode == keys.enter) {
Expand Down Expand Up @@ -311,6 +309,20 @@ $.fn.search = function(parameters) {
}
},

trigger: {
blur: function() {
var
events = document.createEvent('HTMLEvents'),
promptElement = $prompt[0]
;
if(promptElement) {
module.verbose('Triggering native blur event');
events.initEvent('blur', false, true);
promptElement.dispatchEvent(events);
}
}
},

get: {
inputEvent: function() {
var
Expand Down

0 comments on commit 2bae116

Please sign in to comment.