Skip to content
This repository was archived by the owner on Sep 10, 2023. It is now read-only.

Commit b29eedc

Browse files
committed
Update demos to show add/remove/clear
1 parent ef39cc5 commit b29eedc

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

demo.html

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,5 +212,36 @@ <h2 id="onadd-ondelete">Using onAdd and onDelete Callbacks</h2>
212212
});
213213
</script>
214214
</div>
215+
216+
217+
<h2 id="plugin-methods">Using the add, remove and clear Methods</h2>
218+
<div>
219+
<a href="#" id="plugin-methods-add">Add Token</a> | <a href="#" id="plugin-methods-remove">Remove Token</a> | <a href="#" id="plugin-methods-clear">Clear Tokens</a><br />
220+
<input type="text" id="demo-input-plugin-methods" name="blah" />
221+
<input type="button" value="Submit" />
222+
<script type="text/javascript">
223+
$(document).ready(function() {
224+
$("#demo-input-plugin-methods").tokenInput("http://shell.loopj.com/tokeninput/tvshows.php");
225+
226+
// Add a token programatically
227+
$("#plugin-methods-add").click(function () {
228+
$("#demo-input-plugin-methods").tokenInput("add", {id: 999, name: "James was here"});
229+
return false;
230+
});
231+
232+
// Remove a token programatically
233+
$("#plugin-methods-remove").click(function () {
234+
$("#demo-input-plugin-methods").tokenInput("remove", {name: "James was here"});
235+
return false;
236+
});
237+
238+
// Clear all tokens
239+
$("#plugin-methods-clear").click(function () {
240+
$("#demo-input-plugin-methods").tokenInput("clear");
241+
return false;
242+
});
243+
});
244+
</script>
245+
</div>
215246
</body>
216247
</html>

0 commit comments

Comments
 (0)