Select box manipulation with jQuery - update and new plugin

In my plugins for working with select boxes, ajaxAddOption can now call a function after the options have been added. There is also a new plugin (containsOption) for checking if an option with a given value exists.

Comments

Anonymous said…
just tested the update to the plugin for large amount of ptions when using ajaxAddOption and it works very well. great job with this. keep up the good work.
Chris Bloom said…
OK, but how do you use the new fn argument to access the select list? Specifically to call the sortOptions method from the same plugin library.

I've tried function(){this.sortOptions()} as well as function(){arguments[0].sortOptions()}, but neither work. In fact, I don't see any arguments being passed in to the specified function.
Chris Bloom said…
I finally figured it out, but your documentation for that function is wrong. The example shows that you pass a hash, but it should be an array. Here's what finally worked:

var s = $(this).parent().next().find("select");
s.removeOption(/./);
s.ajaxAddOption("/project/contacts", {'id': this.value, 'type': 'onsite', 'info': 'full_name_with_address'}, false, function(){arguments[0].sortOptions()}, [s]);

Popular posts from this blog

Select box manipulation with jQuery

iTextSharp: Generating a Basic PDF file (ASP.NET/C#)

Popup Window Countdown (JavaScript)