Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery ui autocomplete - manipulating results
    primarykey
    data
    text
    <p>I'm returning multiple pieces of data for each result. In each result I have different link's that I am passing that I'd like to make selectable. Right now no matter where someone clicks on a result it just puts the title into the text box rather than processing the link.</p> <pre><code>$(function() { function log(message) { $("&lt;div/&gt;").text(message).prependTo("#log"); $("#log").attr("scrollTop", 0); </code></pre> <p>}</p> <pre><code>$.ajax({ url: "links2.xml", dataType: "xml", success: function(xmlResponse) { var data = $("ROW", xmlResponse).map(function() { return { value: $("SC_DF_FIELD_1", this).text(), url: $("SC_DF_FIELD_2", this).text(), support_url: $("SC_DF_FIELD_3", this).text(), description: $("SC_DF_FIELD_4", this).text(), contact: $("SC_DF_PERSON_LINK", this).text() }; }).get(); $("#birds").autocomplete({ source: data, minLength: 0 }).data( "autocomplete" )._renderItem = function( ul, item ) { return $( "&lt;li&gt;&lt;/li&gt;" ) .data( "item.autocomplete", item ) .append( "&lt;a&gt;" + item.value + "&lt;br&gt;" + item.url + "&lt;br&gt;" + item.description + "&lt;br&gt;" + "Support URL: " + item.support_url + "&lt;br&gt;" + "Contact: " + "&lt;a href=http://someurl.whatever?p_id=" + item.contact + "&gt;Test&lt;/a&gt;" + "&lt;/a&gt;" ) .appendTo( ul ); }; } }) }); </code></pre> <p>So I'd like them to be able to click item.url and it goes there, or item.contact and it goes there.</p> <p>EDIT:</p> <p>This is the formatItem code I'm trying out. It doesn't seam to have any effect on what is returned.</p> <pre><code>function formatItem(item, foo, bar, term){ var temp = item.title + '&lt;br /&gt;&amp;nbsp;&amp;nbsp;' + item.description + '&lt;br /&gt;' + '&lt;a href=' + item.url + '&gt;test&lt;/a&gt;'; return temp; } $.ajax({ url: "links2.xml", dataType: "xml", success: function(xmlResponse) { var data = $("ROW", xmlResponse).map(function() { return { value: $("SC_DF_FIELD_1", this).text(), url: $("SC_DF_FIELD_2", this).text(), support_url: $("SC_DF_FIELD_3", this).text(), description: $("SC_DF_FIELD_4", this).text(), contact: $("SC_DF_PERSON_LINK", this).text() }; }).get(); $("#birds").autocomplete({ source: data, minLength: 0, formatItem: formatItem }) } }) }); </code></pre>
    singulars
    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.
    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