jQuery Autocomplete: How to display tag count? -


With Aotocomplete, I want to display the name (count) as a suggestion when an item is selected, Only the name is printed in the input box. My data format is such as: [{"name": "test", "count": "5"}, {"name": "javascript", "displaying the name without counting The code which can be printed with multi-select items:

  jQuery .gir (function ($) {function split (val) {return valplit (/, \ s * /};} Function actuator list (return) {return split (term). Pop ();} $ ("# ctags-input") .bind ("keydown", function (event) {if (event.keyCode == = $ .ui.keyCode.TAB & amp; $ (this). Data ("AutoComplete"). Menuuactive) {Event.preventDefault ();}}}. Autocomplete ({source: fu} Nction (req, add) {var ctags_action = 'ctags_autosuggest'; $ .getJSON (CTags.url + '? Callback =? And action =' + ctags_action, req, function (data) {var suggestion = []; $ .eich (Data, Function (i, Wall) {suggestions.push (val.name);}) Add (Suggestion);});}, Focus: Function () {Return False;}, Select: Function (Event, UI) {var word = partition (this.value); terms.pop (); Terms.push (ui.item.value); Terms.push (""); This.value = terms.join (",") ; return false; }}); });   

I tried suggestions.push (val) , it does not work I have to do suggestions.push (val.name + "C" + count + ")" Is also tried;); This name can be displayed (count), but when selected, (calculation) is also selected. How can I show the name (calculation) as the only suggestion and input name?

You can combine this example with your multiple value codes and display the count with the items labeled You can:

  $ ("# ctags-input") .bind ("keydown", function (event) {/ * snip * /}). Autocomplete ({source: function (req, add) {var ctags_action = 'ctags_autosuggest'; $ .getJSON (CTags.url + '? Callback =? And action =' + ctags_action, req, function (data) {var suggestions = [ ]; $ .each (data, function (i, val) {suggestions.push ({label: val.name, count: val.count})}}; add (suggestion);},);}, / * Snip *) Data ("AutoComplete") ._Render ITEM = Function (UL, Item) {Return $ ("
  • "). Data ("Item .autocomplete", item ) .append ("& lt; a & gt;" + item.label + "(" + item.count + ") & lt; / a & gt;") .appendTo (ul); };

    Example: (except for the remote part)

  • Comments

    Popular posts from this blog

    Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

    java - How not to audit a join table and related entities using Hibernate Envers? -

    mongodb - CakePHP paginator ignoring order, but only for certain values -