Attaching Typeahead row with anchor tag

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jay123
    New Member
    • Sep 2008
    • 121

    #1

    Attaching Typeahead row with anchor tag

    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

    Code:
    <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.
  • Claus Mygind
    Contributor
    • Mar 2008
    • 571

    #2
    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:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <script type="text/javascript">
    function addtext()
    {
    document.getElementById('anchor1').innerHTML = "my text";
    document.getElementById('anchor1').href = "my_URL";
    }
    </script></head>
    
    <body>
    <input type="button" value="go" onclick="addtext();" />&nbsp;<a id="anchor1" href="#"></a>
    </body>
    </html>

    Comment

    • jay123
      New Member
      • Sep 2008
      • 121

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

      Code:
      updater: function (item) {            
             // do whatever you want to do here
          }

      Comment

      Working...