Skip to content

Instantly share code, notes, and snippets.

@JoshDoody
Last active August 29, 2015 14:09
Show Gist options
  • Select an option

  • Save JoshDoody/174444519da0f8f970f4 to your computer and use it in GitHub Desktop.

Select an option

Save JoshDoody/174444519da0f8f970f4 to your computer and use it in GitHub Desktop.
Dynamic URL with jQuery TokenInput
$(function() {
$(".submission_user_select").tokenInput(getSearchURL, {
crossDomain: false,
prePopulate: $("#submission_user_id").data("pre"),
hintText: "Type a member name...",
tokenLimit: 1,
propertyToSearch: "full_name",
placeholder: "Type a member name...",
theme: "facebook",
resultsFormatter: function(item){ return "<li>" + item[this.propertyToSearch] + "</li>" },
preventDuplicates: true });
});
function getSearchURL() {
return "/teams/"+$(".submission_user_select").attr('data-team-id')+"/team_members.json";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment