so basically what i do is , while user is in the first page i try to get and put content to other pages , i need to call refresh on the element so i don't lose css but i keep getting errors in this part . it's always the page which user is not in that gives me the error
html
<div class="wrapper">
<ul data-role="listview" class="news_list"></ul> </div>
</div>
calling function
$(document).ready(function(e) {
get_latest_news( 1 , 'http://www.xxx.com' , 0 );
})
main function
function get_latest_news(id , link_ , refresh_ ){
var w = $('#'+id).find('.wrapper');
w.hide();
w.find('.news_list').html('');
jQuery.support.cors = true;
$.ajax({
url : link_ ,
success:function(data){
var ul ='' ;
$.each( data.posts , function ( k , v ){
ul += '<li><h3><a href="#each_news">'
+v.title+'</a></h3>'+
'<p > '+v.date+' </p></li>';
});
w.find('.news_list').append(ul);
w.find('.news_list').listview('refresh');
w.show();
}
})
}
i get
Error: cannot call methods on listview prior to initialization; attempted to call method 'refresh'
in this line
w.find('.news_list').listview('refresh');
i change it to
w.find('.news_list')listview().listview('refresh');
now i get
TypeError: parentPage[0] is undefined
[Break On This Error]
parentId = parentUrl || parentPage[ 0 ][ $.expando ],