ruby on rails - create tokens in jquery token input -


presently jquery token input working fine.

am not able create token, not in list

i have seen here, functionality implemented. there no documentation on how can use this.

can 1 me documentation or demo

js_js.js

    $(document).ready(function () {         $("#job_skills").tokeninput("/jobs/search_job_skills", {             theme: "facebook",             preventduplicates: true,             hinttext: 'add skills need job',             searchingtext: 'searching skills...',             allowcreation: true,             creationtext: 'add new element'         });      }); 

cons_controller.rb

  def search_job_skills     search_for_json(skill)   end    def search_for_json(model_search)     @hash = []      @search_res = model_search.where(['name ?', "#{params[:term]}%"])      @search_res.each |tag|       @hash << { id: tag.id,                  name: tag.name}     end     render json: @hash   end 

include allowfreetagging: true when initiate.

unfortunately, documentation hasn't been updated in few years.

also note if set allowfreetagging true, want change tokenvalue "name", because when save tag on server, want save name, not id.

here @ token options

tokenoptions = {     allowfreetagging: true,     tokenvalue: 'name' }  $('input#tag-input').tokeninput('/tags.json', tokenoptions); 

this way, when user selects tags, names sent server, , if there new tag names, create them server-side.


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -