I have the following code:
<div id="widHolder"></div> <script type="text/javascript" language="javascript"> $('#widHolder').widgetName({ optionOne: false, optionTwo: 1, onComplete: function (holder) { </script>
Inside the widget itself, the onComplete method will be called immediately after the widget is fully initialized. I want the code inside the widget to refer to the object that the widget is associated with (in this case, the div with the id "widHolder").
My goal is to be able to quickly and easily refer to the holding object, creating the incomplete function mentioned above. The code in the widget itself will simply call the onComplete function, passing the holder (which I need to get) as a parameter.
Here is sample jQuery UI Widget plugin code
(function ($) { $.widget("ui.widgetName", { options: { // ... other options that can be set onComplete: undefined }, // called on the initialization of the widget _init: function () { // do initialization functions... if(this.options.onComplete) this.options.onComplete( I_WANT_TO_SEND_THE_DOM_ELEMENT_HERE ); }, } })
source share