By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,988 Members | 1,049 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,988 IT Pros & Developers. It's quick & easy.

Attaching Typeahead row with anchor tag

P: 121
I am using ajax call to populate data in my dropdown using Typeahead, now the HTML Typeahead creates for every row in dropdown look like

Expand|Select|Wrap|Line Numbers
  1. <li class="active" data-value="xx"> <a href="#"> my Text </a> </li>
My requiremnt is to have some value in anchor tag where when user clicks on dropdown text, it takes user to new page.

Can anyone point me in right direction? Any help will be appreciated.
Jun 19 '13 #1
Share this Question
Share on Google+
2 Replies

Claus Mygind
P: 571
give your anchor an "id"

then use innerHTML to assign a text to the anchor

or .href to assign a link to the anchor

learn about all the anchor properties clicking here

try this sample code:
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
  2. <html xmlns="">
  3. <head>
  4. <script type="text/javascript">
  5. function addtext()
  6. {
  7. document.getElementById('anchor1').innerHTML = "my text";
  8. document.getElementById('anchor1').href = "my_URL";
  9. }
  10. </script></head>
  12. <body>
  13. <input type="button" value="go" onclick="addtext();" />&nbsp;<a id="anchor1" href="#"></a>
  14. </body>
  15. </html>
Jun 21 '13 #2

P: 121
This can be achieved by using updater attribute in Typeahead as code in updater gets called on click of row in Typeahead dropdown.

Expand|Select|Wrap|Line Numbers
  1. updater: function (item) {            
  2.        // do whatever you want to do here
  3.     }
Jun 21 '13 #3

Post your reply

Sign in to post your reply or Sign up for a free account.