-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plugin restructuration - split things into small pieces #63
Open
michaelperrin
wants to merge
30
commits into
meltingice:master
Choose a base branch
from
michaelperrin:feature/jquery-plugin-structure
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Plugin restructuration - split things into small pieces #63
michaelperrin
wants to merge
30
commits into
meltingice:master
from
michaelperrin:feature/jquery-plugin-structure
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…lity Fix IE7 and IE8 compatibility
Fix compatibility with jQuery 1.9.x
… be an object rather than a function
…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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
constructor
method that instantiates the plugin for a givenselect
element (the constructor is called for each select element corresponding to the selector the plugin is called on)update_list
method that is called each time a change has been done in the search fieldshow_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 theupdate_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.