Is there a way to use jQuery templates (official plugin) with jQuery UI Autocomplete? -


I have found this "hack" to use jTemplates with jQuery UI AutoComplete: < P>

But, what is a way to use the official jQuery template plugin with jQuery UI Autocomplete? I will only use the demo in the link, but if possible it likes the cleaner method.

(It is necessary to use templates because I'm using them somewhere else on the site and want to use a continuous layout for it without having to keep the autocomplete item two versions.) < Well, jQuery UI makes it extremely easy, from the page demo, you simply call .data (). Can change:

  // This is the original code in the demo. Data ("AutoComplete"). 
  • Gt; "+ item.label +" & lt; br & gt; "+ Item.desc +" & lt; / a & gt;) .appendTo (ul); };

    and replace it with. Data () call:

      .data ("autocomplete"). RenderItem = function (ul, item) {return $ ("#myTemplate") .tmpl (item) .appendTo (ul); }; // template & lt; Script id = "myTemplate" type = "text / x-jquery-tmpl" & gt; & Lt; Li & gt; & Lt; A & gt; $ {Label} & lt; Br / & gt; $ {Desc} & lt; / A & gt; & Lt; / Li & gt; & Lt; / Script & gt;   

    And the code working here is in Bella:

  • Comments

    Popular posts from this blog

    mysql - BLOB/TEXT column 'value' used in key specification without a key length -

    c# - Using Vici cool Storage with monodroid -

    python - referencing a variable in another function? -