Question

This tokeninput is from http://loopj.com/jquery-tokeninput/
I see the tutorial from http://railscasts.com/episodes/258-token-fields-revised

As i am using it in many places i need sometime only one value selection while in others multiple values. It is the code for multiple value selction. Now i want it to search only once and submit only one value. Is there any way to code it in my coffescript file to select only one value and stop?

my code for customers.js.coffee
jQuery ->
  $('#customer_plan_tokens').tokenInput '/plans.json'
    theme: 'facebook'
    prePopulate: $('#customer_plan_tokens').data('load')

my code for _form.html.erb for cusomers is
   <div class="form-inputs-right">

            Projects: <%= f.text_field :plan_tokens, data: {load: @customer.plans}, :label => "Projects" %>
        </div>
Was it helpful?

Solution

There is an option in JQueryToken input called as "tokenLimit"....You can set this value to 1 in places where you have to enter only one value. In the other places, you can set the value of token limits accordingly.

Please refer to : http://loopj.com/jquery-tokeninput/

Search for "tokenLimit" for more details. Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top