]> source.dussan.org Git - jquery-ui.git/commitdiff
Widget factory: Added trigger method for triggering callbacks and events.
authorScott González <scott.gonzalez@gmail.com>
Thu, 10 Jul 2008 02:45:02 +0000 (02:45 +0000)
committerScott González <scott.gonzalez@gmail.com>
Thu, 10 Jul 2008 02:45:02 +0000 (02:45 +0000)
ui/ui.core.js

index 2150e497ad3c49af5513b05adf1ce175da09241c..0c8a1164a1b3b53ca67299873cf832c5486abbc7 100644 (file)
@@ -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]);
        }
 };