Im trying to use the jquery tokeninput found here: http://loopj.com/jquery-tokeninput/ Following the guide from railcasts: http://railscasts.com/episodes/258-token-fields
By default, it required a 'name' column on the table/json..
Any way to customize to change it to something else (in my case, 'account_number')?
(in the reailcast, he says if you dont have a 'name' column, youll require extra customization)
Just add the "propertyToSearch" options :
The magical lines are
and
These lines convert the data read from table into the json which jquery-tokeninput can understand. It passes on all the data from the model into, jquery-tokeninput, but it is not necessary. Tokeninput, only needs two fields,
id
-> for each selected token, this is posted along with formname
-> used as label of the tokenIf you don't want to have a
name
field in your model, and want to useaccount_number
as the label, you can do it like following:and
Basically, change the json passed to tokeninput. Pass
accoun_number
asname
.Update:
Change this line to something which better suits you:
One suggestion may be:
Remove the first
%
, but really depends on your data type and all.