views:

9

answers:

1

hi there,

I am making a jquery plugin.

I am trying to create a jquery plugin,

I am attempting to add the ability for users the run a function at certian times.

so, in the option array the user could have

{created: function(){alert('created called!');}}

Now in the plugin,

How do i run that code?

i tried just

options.created and eval(options.created);

but neither have any effect.

What am i doing wrong?

A: 

Have you tried options.created()?

More info: When you set a variable to an anonymous function in JavaScript, you must call the variable the same way you would any "regular" function. This allows you to pass parameters to the function.

For example:

var aFunction = function(a, b) { alert(a + " " + b); };

aFunction('Hello', 'world');
Dan D.