Reputation: 833
So to initialize autocomplete for a textbox, you do this $('#textbox').autocomplete({...});
I have a custom widget declared:
$.widget( "custom.catcomplete", jQuery.ui.autocomplete, {
......
});
In this case the widget's name is catcomplete
, so to initialize a custom autocomplete, you can do this: $('#textbox').catcomplete({...});
Now comes the tricky part. I'm trying to call $('#textbox').catcomplete({...});
using a variable name, in this way:
var w = 'catcomplete';
//this is where i try to call the widget
$('#textbox').{w}({...}); // <-- this is obviously wrong
While the example is obviously wrong, but I hope it gives a generally good idea of what I'm trying to do. By the way the widget cannot be modified (legacy issues).
Thanks in advanced!
Upvotes: 0
Views: 105
Reputation: 6467
This simple code works to call jQuery.find method (get the first div inside the body):
$('body')['find']('div:first')
So, the solution for you should be something like this:
$('body')[yourVariable]({...})
Upvotes: 1