I've a basic jquery plugin where uses data attributes data-something="thing" to tell the plugin what function run inside of it.
I was using the next to do it:
// Plugin definition.
$.fn.plugin = function( options ) {
// Iterate and reformat each matched element.
return this.each(function() {
var func = element.data('something');
var response = plugin[func]($(this));
});
};
And it works just fine. But i wanted to follow the jquery standars where functions should be called:
$.fn.plugin.thing($(this));
So...the question. How to archive that? Is that possible when the same of the function comes in text?
Thanks!
$.fn.plugin['thing'](..);