views:

20

answers:

2

Hi,

Currently the autocomplete action when pressing the enter key on a selected element is to put that elements value into the input box.

How can I modify the behavior so that pressing the enter key on an element triggers that elements embedded url. To simplify I'd like to make the enter key have the same behavior as a mouse click on a returned element.

Thanks

A: 

This is the function that is called when you select an item and hit enter. The hacky code you see in this function extracts the href from the link and redirects to that url.

$("#searchBox").result(function(event, data, formatted) {
        var p = data.toString();
        p = p.replace('<a href="', '');
        var url = p.substr(0, p.indexOf('"'));
        p = p.replace('</a>', '');
        p = p.substr(p.indexOf('>') + 1, p.length - p.indexOf('>') - 1);
        window.location = "" + url;
        return false;
    });
James Lawruk