I am at a dead end with this, I was at this hour trying to get jQuery autocomplete to go to another page on the site when the item clicked in the list of offers.
Does anyone know how to do this? Here is my code:
$(':input[data-autocomplete]').autocomplete({ source: $(':input[data-autocomplete]').attr("data-autocomplete"), delay: 0, select: function (event, item) { //window.location.replace("http://www.example.com/Profile/Details/1");// Works but totally unacceptable, browser history lost etc.. //alert("Item Clicked"); //Fires Ok } }).data("autocomplete")._renderItem = function (ul, item) { var MyHtml = '<a id="ItemUrl" href="/Profile/Details/' + item.PartyId + '"' + ">" + "<div class='ac' >" + "<div class='ac_img_wrap' >" + '<img src="../../uploads/' + item.imageUrl + '.jpg"' + 'width="40" height="40" />' + "</div>" + "<div class='ac_mid' >" + "<div class='ac_name' >" + item.value + "</div>" + "<div class='ac_info' >" + item.info + " PartyId :" + item.PartyId + "</div>" + "</div>" + "</div>" + "</a>"; return $("<li></li>").data("item.autocomplete", item).append(MyHtml).appendTo(ul); };
As you can see, I used my own HTML in the _renderItem
event, my custom HTML creates a binding with the identifier passed from the source, it looks fine, the link is correctly formed in the lower left corner of the browser (I use Chrome)
<a href='/Profile/Details/id' >some other divs & stuff</a>
The problem is that when I click the link, nothing happens, I tried to use the select event, but the element is null, so I can not force item.PartyId
force manual transition.
How can I make the click event work?
source share