jquery 1.7.2 using template to dynamically update list view -


first of new jquery , jquerymobile sorry if question stupid. trying port old project (written in jq 1.6.4 jqm 1.0b1) jq 1.7.2 + jqm 1.1.0. there part uses templates plug-in dynamically update list view parsing json.

html code:

... <ul data-role="listview" id="myitems" data-inset="true"></ul>  ...  

template:

<script id="mylistitem" type="text/x-jquery-tmpl"> <li>     <div class="ui-li-almost-right"><button id="editbutton">edit</button></div>     <a href="javascript:true" id="connectlink">${symname}&nbsp;</a> </li> </script> 

updating list:

$(items).each(function (i, item) {     var mytemplate=$("#mylistitem").tmpl(item);     mytemplate.appendto($("#myitems")); }); $("#myitems").listview("refresh"); 

with new version if jq , jqm list items generated class "ui-page" , result stretched vertically. can tell me why happening , how avoid it?

thank you.

you may use next-gen jquery template: jsrender, with:

template:

<script id="mylistitem" type="text/x-jquery-tmpl"> <li>     <div class="ui-li-almost-right"><button id="editbutton">edit</button></div>     <a href="javascript:true" id="connectlink">{{:symname}}&nbsp;</a> </li> </script> 

to update list data.items:

var datalist = $( "#mylist" ); // create items using template & add list datalist.append( $("#mylistitem").render( data.items ) ); // call listview jquery ui widget correct rendering datalist.listview( "refresh" ); 

hope helps.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -