Search code examples
jqueryruby-on-railsrubyjquery-tokeninput

In rails, using jquery token input and the tags are not working


<div class="field">
    <%= f.label :author_tokens, "Authors" %><br />
    <%= f.text_area :author_tokens, "data-pre"=> @article.authors.map(&:attributes).to_json %>
  </div>

This is my field for tokens. all authors name is listed here sucessfully. But when I choose them they are not copied in textarea author_tokens. but other name beside the option are copied in textfield.

{"utf8"=>"✓",
 "authenticity_token"=>"4XajxI5Cw59/Oe/Di0vlZKG2wp61/plh12iIs+OrKaI=",
 "article"=>{"name"=>"fdsfds",
 "published_on(1i)"=>"2012",
 "published_on(2i)"=>"8",
 "published_on(3i)"=>"21",
 "author_tokens"=>"",
 "content"=>"fdsfsfds"},
 "commit"=>"Create Article"}

what could be the problem?


Solution

  • Just put this in your html.erb file.

    <% f.text_field :name_of_the_date_column, :value=>Date.today.strftime('%m-%d-%Y'), :id=>"dp5" %>
    

    and in apllication.js file

    $("#dt5").datepicker({
            format: 'mm-dd-yyyy'
        })
    .on('changeDate', function(ev){
      $('#dt5').datepicker('hide');
    });
    

    This works for me