RailsCasts Pro episodes are now free!

Learn more or hide this

ericn7's Profile

GitHub User: ericn7

Comments by

Avatar

I ran into problems when trying to use more than one token input field on one page. Here is how I changed the code to make it work:

$(function () {
//$('#item_tag_tokens').tokenInput('/tags.json', {
$(".token_input").tokenInput('/tags.json', {
crossDomain: false,
//prePopulate: $('#postyle_tag_tokens').data('pre'),
prePopulate: $(this).data('pre'),
tokenValue: 'name',
theme: 'facebook'
});
});

and in the view:

<%= text_field_tag 'postyle_tag_tokens','', "data-pre" => postyle.tags.map(&:attributes).to_json, :class => "token_input" %>