From d70f4f7620b97b119bba5a8cdf8f6fd1d7d5475c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Scott=20Gonz=C3=A1lez?= Date: Thu, 10 Jul 2008 02:45:02 +0000 Subject: [PATCH] Widget factory: Added trigger method for triggering callbacks and events. --- ui/ui.core.js | 8 ++++++++ 1 file changed, 8 insertions(+) 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]); } }; -- 2.39.5