javascript - Twitter typeahead different value to display -
//javascript var customer = new bloodhound({ datumtokenizer: bloodhound.tokenizers.obj.whitespace('name'), querytokenizer: bloodhound.tokenizers.whitespace, prefetch: 'include/customer.json' }); $('.typeahead').typeahead(null, { name: 'customer', display: 'name', source: customer }); //json [ {"identity":"1","name":"uzumaki naruto"}, {"identity":"2","name":"monkey d. luffy"}, {"identity":"3","name":"ichigo kurosaki"} ] //html <input class="typeahead" type="text" name="customer"/>
is possible in typeahead plugin search , display 'name
' , when submit form give me value of 'identity
'. btw i`m using 0.11.1v of typeahead. tia
to accomplish want, have use 2 input fields.
// html <input type="text" name="customer_typeahead" class="typeahead"/> <input type="hidden" name="customer" id="customer_identity" /> // typeahead code $('.typeahead').typeahead(null, { .... }).bind('typeahead:select', function(ev, suggestion) { $('#company_identity').val(suggestion.identity); });
this makes when select suggestion, set value of customer
input.
Comments
Post a Comment