javascript - Twitter typeahead hidden field -


I am using a page to suggest a list of books on the search page, all this works as expected , But now I'd like to add another field to the hidden field.

Most of the tutorials I see look dated.

My HTML form follows:

  & lt; Form id = "search" action = "& lt ;? Php echo URL;;> Books / Idioms? Id =" method = "post" & gt; & Lt; Input type = "text" name = "search" class = "typeahead" id = "demo" /> & Lt; Input type = "text" name = "isbn" type = "hidden" class = "typeahhead" id = "isbn" /> & Lt; Input type = "submit" value = "submit" style = "" & gt; & Lt; / Form & gt;  

I am able to retrieve a list of suggestions from my Jason file. I'm also able to click on one of these and choose one of them. It places the id in my input field; I also want to put isbn in the hidden area, how is this possible.

My JS is down;

  $ (document) .ready (function () {var url = 'http: // localhost / logintest /'; var books = new bloodbands ({DataTokinator: bloodhound.tokenizers.obj. Whitespace ('title'), QueryToToken: Bloodhound.tokenizers white spot, range: 3, prefetch: {url: url + 'books.json', ttl: 0, filter: function (list) {return $ .map (list, Function (book) {return {id: book.id, title: Book.title, author: book.author, isbn: book.isbn};});}}}) Books. Initial (); $ ('.demo Type ''). TypeHead (empty, {displayKey: 'id', // come in the search bar in the selection bar D displays: Handlar, templates: {Header: '& lt; h1 & gt; name & lt; / h1 & gt;', empty: ['

It's well-know that this is the answer, add it under typeahead function

  $ ('input.query'). ('Typeahead: selected', function (e, datum) {console.log (datam ['empID']);});   

Change empID to whatever you want to log.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -