Where in the jQuery object is the object that defines a UI widget stored?
I am creating a set of custom jQuery UI widgets for a web page. User interaction with the page will add one or more of these widgets to the DOM. At the point where this happens, there will be no element in the DOM for the widget to attach itself to. I want to write my custom widgets so that they can be used both like a normal UI widget, and also as an on-the-fly addition.
Let me give an example. This is how I would convert an existing element in the DOM to a custom widget:
HTML snippet:
<div id="customWidgetsParent">
<table class='custom-tableWidget'></table>
</div>
JS snippet:
(function($) {
$.widget(
"custom.tableWidget"
, { options: {}
, rootElement: "<table></table>"
, _create: function create() {
// CODE to create a custom table widget
}
}
)
})(jQuery)
Notice the rootElement property. My custom widgets will all require different types of HTMLElement to attach themselves to.
Here's what I want to be able to do, starting with an empty parent element:
HTML snippet:
<div id="customWidgetsParent"></div>
JS snippet:
var widgets = {
"custom.tableWidget": {
colNames: ["Column 1", "Column 2", "Column 3"]
, rowNames: ["Row 1", "Row 2"]
}
}
createCustom(widgets, $("#customWidgetsParent"))
In the createCustom() function, I would like to be able to access the definition of the custom.tableWidget, so that I can retrieve the value of its rootElement property. I can then append an element of that type to the parent element, and then convert this newly-added element into a widget.
Where in the jQuery object is this widget definition object stored?