From: Scott González Date: Thu, 10 Jul 2008 02:45:02 +0000 (+0000) Subject: Widget factory: Added trigger method for triggering callbacks and events. X-Git-Tag: 1.6rc2~222 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d70f4f7620b97b119bba5a8cdf8f6fd1d7d5475c;p=jquery-ui.git Widget factory: Added trigger method for triggering callbacks and events. --- diff --git a/ui/ui.core.js b/ui/ui.core.js index 2150e497a..0c8a1164a 100644 --- a/ui/ui.core.js +++ b/ui/ui.core.js @@ -108,6 +108,7 @@ $.widget = function(name, prototype) { var self = this; this.widgetName = name; + this.widgetEventPrefix = $[namespace][name].eventPrefix || name; this.widgetBaseClass = namespace + '-' + name; this.options = $.extend({}, $.widget.defaults, $[namespace][name].defaults, options); @@ -151,6 +152,13 @@ $.widget.prototype = { }, disable: function() { this.setData('disabled', true); + }, + + trigger: function(type, e, data) { + var eventName = (type == this.widgetEventPrefix + ? type : this.widgetEventPrefix + type); + e = e || $.event.fix({ type: eventName, target: this.element[0] }); + this.element.triggerHandler(eventName, [e, data], this.options[type]); } };