Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to redirect to another page with jQuery Autocomplete item click
    primarykey
    data
    text
    <p>I'm stumped with this one, I've been at it hours, trying to get jQuery autocomplete to go to another page on the site when an item is clicked in the suggestions list.</p> <p>Anyone know how to do this? Here is my code :</p> <pre><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 = '&lt;a id="ItemUrl" href="/Profile/Details/' + item.PartyId + '"' + "&gt;" + "&lt;div class='ac' &gt;" + "&lt;div class='ac_img_wrap' &gt;" + '&lt;img src="../../uploads/' + item.imageUrl + '.jpg"' + 'width="40" height="40" /&gt;' + "&lt;/div&gt;" + "&lt;div class='ac_mid' &gt;" + "&lt;div class='ac_name' &gt;" + item.value + "&lt;/div&gt;" + "&lt;div class='ac_info' &gt;" + item.info + " PartyId :" + item.PartyId + "&lt;/div&gt;" + "&lt;/div&gt;" + "&lt;/div&gt;" + "&lt;/a&gt;"; return $("&lt;li&gt;&lt;/li&gt;").data("item.autocomplete", item).append(MyHtml).appendTo(ul); }; </code></pre> <p>As you can see I have used custom HTML in the <code>_renderItem</code> event, my custom HTML creates an anchor tag with the id passed in from the source, this looks ok, the link is formed correctly in the browser bottom left corner (I'm using Chrome)</p> <pre><code>&lt;a href='/Profile/Details/id' &gt;some other divs &amp; stuff&lt;/a&gt; </code></pre> <p>The problem is that when I click the link nothing happens, I have tried using the select event but item is null so can't get <code>item.PartyId</code> to force a manual jump.</p> <p>How can I get the click event working?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload