javascript - Jquery Mobile: How to style dynamically added list items when listview() function does not work? -
i new jquery mobile , jquery in general , have run problem. have been populated list using 2 ajax calls (data 2 sources). second call located within first executed after it. calls identical apart source of data , follows:
html:
<ul data-role="listview" data-inset="true" data-theme="a" data-filter="true" id="allvideoslist"> <li><a href="#">this item styled properly</a></li> </ul>
javascript:
var html = ""; var id = 0; var displayname = "name"; $.ajax({ type:'get', url: xxxx data: xxxx datatype: 'jsonp', success: function processresult(data) { .... html += '<li data-filtertext="' + resultdata.name + ' ' + date + '"><a href="index.html?id=' + id + '">' + displayname + '</a></li>'; $('#allvideoslist').append(html); });
variables defined within ajax call omitted here. list created lacks style, each item appears link. function:
$('#allvideoslist').listview('refresh');
or
$('#allvideoslist').listview();
returns error
$(...).listview
not function
in console. function:
$('#allvideoslist').trigger('create');
does not change anything.
if print variable html console, copy contents, , add list in different page, style applied properly. example:
html:
<div data-role="content" id="list"> <ul data-role="listview" data-inset="true" data-theme="a" data-filter="true" id="allvideoslist"> </ul> javascript: var html = ""; html = '<li data-filtertext="insert text here"><a href="index.html?id=146">name</a></li><li data-filtertext="insert text here 2"><a href="index.html?id=147">name 2</a></li>' $("#allvideoslist").append(html)
works fine. how can apply style dynamically loaded list?
i similar in 1 of projects. had similar trouble code works me...
$("#mylist").append(myjsonobject.somelistitems).listview("refresh");
as can see, can add listview function call in same line append call. without more of code, it's hard tell if resolve issue.
Comments
Post a Comment