Skip to content

Conversation

@michaelperrin
Copy link

Hi Ryan,

It's been a little why I didn't contribute to your project!
I'm now back with this apparently pretty big pull request that restructures your plugin for more flexibility.

I transformed the plugin to something that looks more like a standard jQuery plugin (see for example http://jqueryboilerplate.com/) and I split the whole main function into smaller pieces, making things easier to understand.

There are now 3 main methods:

  • A constructor method that instantiates the plugin for a given select element (the constructor is called for each select element corresponding to the selector the plugin is called on)
  • A update_list method that is called each time a change has been done in the search field
  • A show_results method that displays the results after an AJAX call has been made.

There is one more method which is called register_observers that register observers to call the update_list method.

This allowed me to add a small new feature: the minTermLength parameter can now be set to 0 so that a search is made even at the first click on the Chosen element.

It seems really big code change but don't be afraid, it's mostly about blocks cut & pasted.

All backward compatibility is preserved and all compiled files have been generated (JS, minified JS) using cake.

If you have any concerns about code structure, naming conventions or anything else, feel free to ask!

And sorry about previous commits shown in this PR, this is because I changed my username.

michaelperrin and others added 30 commits October 8, 2012 17:35
…gin-structure

Conflicts:
	lib/ajax-chosen.js
	lib/ajax-chosen.min.js
	src/ajax-chosen.coffee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants