r3187 committed - dev widget factory: Store plugin instances in $.data after constructio...

r3187 committed - dev widget factory: Store plugin instances in $.data after constructio...


Revision: 3187
Author: scott.gonzalez
Date: Wed Sep 2 18:24:40 2009
Log: dev widget factory: Store plugin instances in $.data after
construction.
http://code.google.com/p/jquery-ui/source/detail?r=3187
Modified:
/branches/dev/widget-factory/ui/ui.core.js
=======================================
--- /branches/dev/widget-factory/ui/ui.core.js    Thu Jul 30 18:23:37 2009
+++ /branches/dev/widget-factory/ui/ui.core.js    Wed Sep 2 18:24:40 2009
@@ -247,8 +247,6 @@
};
$.widget.bridge = function(name, object) {
-
-    // create plugin method
    $.fn[name] = function(options) {
        var isMethodCall = (typeof options == 'string'),
            args = Array.prototype.slice.call(arguments, 1),
@@ -271,7 +269,7 @@
                }
            })
            : this.each(function() {
-                ($.data(this, name) || new object(options, this));
+                ($.data(this, name) || $.data(this, name, new object(options, this)));
            }));
        return returnValue;
@@ -290,6 +288,8 @@
        disabled: false
    },
    _widgetInit: function(options, element) {
+        // $.widget.bridge stores the plugin instance, but we do it anyway
+        // so that it's stored even before the _init function runs
        this.element = $(element).data(this.widgetName, this);
        this.options = $.extend(true, {},
            this.options,