Reputation: 1
Im trying to write a small jQuery plugin and be able to change the effects (fadeIn, slideDown etc etc) with options but am having no luck working out how to, for example if I was to add this
fx : fadeIn
then it would change this:
$('.foo').opts.fx('slow');
This issue I seem to have is that it doesen't like the placement of the option so am I suppost to wrap it somehow?
Upvotes: 0
Views: 313
Reputation: 86854
I'm no jQuery guru, but since there are no responses, I'll give it a try.
This seems to work for me:
if ($.isFunction($('#foo')[opts.fx])) { // check if it's a valid function
$('#foo')[opts.fx]("slow");
} else {
// ... use default effect ...
}
See demo.
Upvotes: 1