Skip to content

Commit

Permalink
Fix issue knockout#57 - when registering event handlers through jQuer…
Browse files Browse the repository at this point in the history
…y, also trigger event handlers through jQuery
  • Loading branch information
SteveSanderson committed Apr 5, 2011
1 parent 0ea4695 commit 1cbe9c5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
4 changes: 3 additions & 1 deletion build/output/knockout-latest.debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,9 @@ ko.utils = new (function () {
if (!(element && element.nodeType))
throw new Error("element must be a DOM node when calling triggerEvent");

if (typeof document.createEvent == "function") {
if (typeof jQuery != "undefined") {
jQuery(element)['trigger'](eventType);
} else if (typeof document.createEvent == "function") {
if (typeof element.dispatchEvent == "function") {
var eventCategory = (eventType == "click" ? "MouseEvents" : "HTMLEvents"); // Might need to account for other event names at some point
var event = document.createEvent(eventCategory);
Expand Down
14 changes: 7 additions & 7 deletions build/output/knockout-latest.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ ko.utils = new (function () {
if (!(element && element.nodeType))
throw new Error("element must be a DOM node when calling triggerEvent");

if (typeof document.createEvent == "function") {
if (typeof jQuery != "undefined") {
jQuery(element)['trigger'](eventType);
} else if (typeof document.createEvent == "function") {
if (typeof element.dispatchEvent == "function") {
var eventCategory = (eventType == "click" ? "MouseEvents" : "HTMLEvents"); // Might need to account for other event names at some point
var event = document.createEvent(eventCategory);
Expand Down

0 comments on commit 1cbe9c5

Please sign in to comment.