I have the following code:
<div id="widHolder"></div>
<script type="text/javascript" language="javascript">
$('#widHolder').widgetName({
optionOne: false,
optionTwo: 1,
onComplete: function (holder) {
// ... do something here with the 'widHolder' object such as $(holder).addClass(x,y)
}
});
</script>
Within the widget itself, the onComplete method will be called immediately after the full initialization of the widget. I want the code within the widget to reference the object that the widget is linked to (in this case, the div with the id 'widHolder').
My goal is to be able to quickly and easily reference the holding object by creating the oncomplete function as listed above. The code in the widget itself will just be to call the onComplete function passing the holder (which I need to get) as a parameter.
Here is the code sample of the jQuery UI Widget plugin
(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 );
},
}
})