How do I refresh the CSS for a DIV loaded with external content in JQuery Mobile

十年热恋 提交于 2019-12-14 03:25:36

问题


I have read all of your comments, but none of the solutions I read seem to work. I have a piece of Jquery code that gets some content from an external PHP script which updates a div in my application. After the new data is loaded, it doesn't have the Jquery Mobile styling. I've seen how some have used .page() or trigger("refresh"), etc... but none of that works to refresh an entire div. Here is my code and the portion of html in question:

function getcontent(pg) {
   $("xyz").html("");
   $.get("http://myscript.php", function(data) {
      $("#xyz").html(data);
      $("#xyz").page();
}

HTML:

<div id="xyz"></div>

Really, there's not much to this at all and I just can't figure this out. I had "some" success if I removed the wrapper div ("xyz") and just refreshed the individual elements' listview, buttons, etc., but that's a terribly clumsy method of handling this.


回答1:


One the page containing #xyz, e.g. #mypage, call

$('#mypage').trigger('pagecreate');



回答2:


I used the .page element on the list or div that has the refresh

$('ul.sessions-list *').page();

This refreshes everything in my sessions-list that was loaded, externally and corrects the css.




回答3:


try using

$("#page_id").trigger("create")

on the page that gets the content added to.



来源:https://stackoverflow.com/questions/10231122/how-do-i-refresh-the-css-for-a-div-loaded-with-external-content-in-jquery-mobile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!