Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery autocomplete display the output string
    primarykey
    data
    text
    <p>I want to have the script display each item on a list of value from a string of comma delimited set.</p> <p>ex. "one,two,three,four"</p> <p>On the autocomplete drop down, it should show:</p> <p>one two three four</p> <p>However, the current code, show a list of only single char. There should be an easy way to split that list up and display the word instead of char. My javascript is a little limited, if someone can figure it out for me, I would appreciated. thanks. I have been search around and know that you should be able to override the parse function but it has to be easier than that. Also, I am using a webservice to return the string and can be delimited by anything but it needs to show the word. </p> <p>If anyone knows the answer, I would appreciated...thanks</p> <pre><code> $("#CustomerID").autocomplete({ source: function(request, response) { $.ajax({ type: "POST", url: "/customer/search.asmx/findvalue", dataType: "json", data: { term: request.term }, error: function(xhr, textStatus, errorThrown) { alert('Error: ' + xhr.responseText); }, success: function(data) { response($.map(data, function(item) { return { label: item, value: item } })); } }); }, minLength: 2, select: function(event, ui) { alert('Select'); } }); </code></pre> <p>EDIT----------------------</p> <p>Thank you to the previous poster for help answering.</p> <p>It seems to be the nuances of the formatting or something.</p> <p>This works:</p> <pre><code>success: function (data) { response($.map(data, function (item) { return item.split(","); })); }, </code></pre> <p>Using this seems to just error out or does nothing:</p> <pre><code> success: function(data) { response(data.split(",")); } </code></pre> <p>I even tried this, it goes through but does not result in a drop down menu:</p> <pre><code>success: function (data) { response($.map(data, function (item) { response(item.split(",")); })); }, </code></pre> <p>The above seem to work and displays what I want, not sure if it's efficient. If someone wants to explain why? Not sure why in some case you would need a response() and/or a return inorder for the autocomplete to work....</p>
    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.
 

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