0

I'm writing a jQuery plugin, pretty basic modal window plugin.

All of the modal windows will have an action button, which will either "save" "send" or "ok" etc. As well as possibly more things in the future. Where is the best place to make this call. Should I build it into the plugin, or is there a better way of keeping the call separate from the plugin? I guess the thought is that if I had it outside the plugin, it would open the door for a lot of custom actions for whatever situation I need. Not sure how easy it would be to bind click events to a button in a modal window being generated in a plugin though. Any thoughts? Thanks!

1

1 Answer 1

1

There are many options, but without understand exactly what you're doing, I would think that a callback would be a good option.

For example, the plugin's "save" handler would call options.saveCallback.call(this);

So you create a saveCallback option, and pass it in when you initialize your plugin. There's a good example of this here: jQuery Plugin: Adding Callback functionality

Now if people. want to customize what the save button does, they can use the callback.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.