Reputation: 2048
I have initialized my plugin but I keep getting cannot call methods on collapsableTabs prior to initialization
when I try to call a method in the plugin.
The plugin is loaded and appears fine. I have an input control on the page:
<input type="button" id="allOptions" value="Options:" onclick="javascript:populateOptions();" />
...
function populateOptions()
{
var optionSelector = $(this).collapsableTabs('allOptions'); <-- FAILS
}
When I click on the button, I get the error
message.
How do I get around this?
Upvotes: 2
Views: 2467
Reputation: 81
You must first initialize the widget before calling methods on it, ie:
$(this).collapsableTabs().collapsableTabs("allOptions")
One alternative to this clunky syntax would be to call allOptions() from within the _create() or _init() methods of the widget itself.
Upvotes: 2