How to instantiate JQuery UI widget by string?

Posted by limcheekin on Stack Overflow See other posts from Stack Overflow or by limcheekin
Published on 2011-01-06T13:44:37Z Indexed on 2011/01/06 13:53 UTC
Read the original article Hit count: 296

Filed under:
|
|

Hi there,

Do you know how to instantiate JQuery UI widget by string?

Let's illustrate it with some sample code. Given the html link element below:

<a id="testLink" href="#">Test Link</a>

Normally, we can make it into button using code below:

$('#testLink').button();

What if I want to instantiate the button with string, for example:

var widget='button';
$('#testLink').[widget]();

Of course the code block above is not working (It is just for illustration purpose only), otherwise you will not see this question.

Please advice.

Thanks,

Chee Kin

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about jquery-ui