In Jquery i'd like to disable any plugin I want by changing a variable name. However the following code doesnt work
function disablePlugin(functionName) {
$('#divID').functionName('disable')
}
disablePlugin('sortable');
any ideas about how I manage to do this?
This is how you would do that:
function disablePlugin(functionName) {
$('#divID')[functionName]('disable')
}
disablePlugin('sortable');
This works because someObject.foo
is the same thing as someObject['foo']
To invoke the function passed in as a string, you could do
function disablePlugin(functionName) {
$('#divID')[functionName]('disable')
}
disablePlugin('sortable');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With