Permalink
Browse files

Merge branch 'master' of github.com:loopj/jquery-tokeninput

  • Loading branch information...
loopj committed Aug 4, 2011
2 parents 5e8e842 + 08ebdaf commit a1af7f98f10c8b09fa24a96adc1acd078d0d2fa4
Showing with 30 additions and 0 deletions.
  1. +19 −0 demo.html
  2. +11 −0 src/jquery.tokeninput.js
View
@@ -161,6 +161,25 @@ <h2 id="pre-populated">Pre-populated</h2>
</div>
+ <h2 id="pre-populated-with-tokenlimit">Pre-populated &amp; Token Limit</h2>
+ <div>
+ <input type="text" id="demo-input-pre-populated-with-tokenlimit" name="blah" />
+ <input type="button" value="Submit" />
+ <script type="text/javascript">
+ $(document).ready(function() {
+ $("#demo-input-pre-populated-with-tokenlimit").tokenInput("http://shell.loopj.com/tokeninput/tvshows.php", {
+ prePopulate: [
+ {id: 123, name: "Slurms MacKenzie"},
+ {id: 555, name: "Bob Hoskins"},
+ {id: 9000, name: "Kriss Akabusi"}
+ ],
+ tokenLimit: 3
+ });
+ });
+ </script>
+ </div>
+
+
<h2 id="disable-animation">Disable Animation on Dropdown</h2>
<div>
<input type="text" id="demo-input-disable-animation" name="blah" />
View
@@ -34,6 +34,7 @@ var DEFAULT_SETTINGS = {
onResult: null,
onAdd: null,
onDelete: null,
+ onReady: null,
idPrefix: "token-input-"
};
@@ -358,6 +359,10 @@ $.TokenList = function (input, url_or_data, settings) {
});
}
+ // Initialization is done
+ if($.isFunction(settings.onReady)) {
+ settings.onReady.call();
+ }
//
// Public functions
@@ -456,6 +461,12 @@ $.TokenList = function (input, url_or_data, settings) {
token_count += 1;
+ // Check the token limit
+ if(settings.tokenLimit !== null && token_count >= settings.tokenLimit) {
+ input_box.hide();
+ hide_dropdown();
+ }
+
return this_token;
}

0 comments on commit a1af7f9

Please sign in to comment.