diff options
author | Scott González <scott.gonzalez@gmail.com> | 2008-07-10 02:45:02 +0000 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2008-07-10 02:45:02 +0000 |
commit | d70f4f7620b97b119bba5a8cdf8f6fd1d7d5475c (patch) | |
tree | fc69cc29eab0fc39baaadf6744f49b03bc106756 /ui/ui.core.js | |
parent | 717630f6e0befd47249c1472ab5e25e8d9d329dd (diff) | |
download | jquery-ui-d70f4f7620b97b119bba5a8cdf8f6fd1d7d5475c.tar.gz jquery-ui-d70f4f7620b97b119bba5a8cdf8f6fd1d7d5475c.zip |
Widget factory: Added trigger method for triggering callbacks and events.
Diffstat (limited to 'ui/ui.core.js')
-rw-r--r-- | ui/ui.core.js | 8 |
1 files changed, 8 insertions, 0 deletions
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]); } }; |