[jQuery] Re: Add callback to plugin?

2008-11-06 Thread Mike Nichols
Why not take advantage of jquery's event mechanism and do an event based api, like: $("#sel").testStatus(opt).bind("statusupdated.testStatus",function() { //dostuff }); then in your plugin: if (question) { $.ajax({ type: 'POST', url: itemHref + defaults.status

[jQuery] Re: Add callback to plugin?

2008-11-06 Thread Hector Virgen
I would add it as an option and set its default value to an empty function: var defaults = { status: '?action=live', onComplete: function() {} } That way you could safely call onComplete when ready and it will either do nothing or call the user-supplied function. -Hector On Thu, Nov 6,