Jquery mobile Ajax对jquery移动页面的调用是有效的,但刷新时会丢失css和js功能

Jquery mobile Ajax对jquery移动页面的调用是有效的,但刷新时会丢失css和js功能,jquery-mobile,Jquery Mobile,我将下面的代码加载到jquery移动页面数据角色中。我注意到的两件奇怪的事情是,如果我尝试只加载其中的一个页面,而不加载css或jquery mobile功能,只加载从脚本加载的项目。另一件事是,在页面刷新时,它也会丢失它。数据仍然显示为纯文本。还有其他人经历过吗?我也尝试了pagecreate函数,而不是documentready,但它根本不起作用。有人能理解为什么它会在手机上这样做,或者提出一些建议吗 提前谢谢 <script> $(document).ready(func

我将下面的代码加载到jquery移动页面数据角色中。我注意到的两件奇怪的事情是,如果我尝试只加载其中的一个页面,而不加载css或jquery mobile功能,只加载从脚本加载的项目。另一件事是,在页面刷新时,它也会丢失它。数据仍然显示为纯文本。还有其他人经历过吗?我也尝试了pagecreate函数,而不是documentready,但它根本不起作用。有人能理解为什么它会在手机上这样做,或者提出一些建议吗

提前谢谢

<script>
   $(document).ready(function(){

                      $.ajax({
                             type: "GET",
                             url: "oncology_testlist.xml",
                             dataType: "xml",
                             success: function(xml) {
                             var $ul = $("#testList");
                             var categories = new Object();
                             var category;
                             $(xml).find('test').each(function(){
                                                      category = $('category', this).text();
                                                      cat_nospaces = category.replace(/ /g,'');
                                                      if (!$('#cat_'+cat_nospaces).length) {
                                                      $ul.append('<div data-role="header" data-theme="a" id="cat_'+cat_nospaces+'"><h1>' + category + '</h1></div>');
                                                      }
                                                      $ul.append('<li><div data-role="collapsible" data-collapsed="true" data-theme="b">'
                                                                                     + '<h3>' + $('test_code', this).text() + " - " + $('name', this).text() + '</h3>'
                                                                                     + (!$.trim($('cpt_code', this).text())?'':'<p>' + "CPT Code(s): " + $('cpt_code', this).text() + '</p>')
                                                                                     + (!$.trim($('method', this).text())?'':'<p>' + "Method: " + $('method', this).text() + '</p>')
                                                                                     + (!$.trim($('clinical_utility', this).text())?'':'<p>' + "Clinical Utility: " + $('clinical_utility', this).text() + '</p>')
                                                                                     + '</div></li>');

                                                      });
                             }
                             }); 
                      });
    </script>    

$(文档).ready(函数(){
$.ajax({
键入:“获取”,
url:“oncology_testlist.xml”,
数据类型:“xml”,
成功:函数(xml){
var$ul=$(“#测试列表”);
var categories=新对象();
var类别;
$(xml).find('test').each(function(){
category=$('category',this).text();
cat_nospaces=category.replace(//g',);
if(!$('#cat_u'+cat_unospaces).length){
$ul.附加(“”+类别+“”);
}
$ul.append(“
  • ” +'+$('test_code',this.text()+“-”+$('name',this.text()+“” +(!$.trim($('cpt_code',this).text())?“”:“”+“cpt code:”+$('cpt_code',this).text()+“

    ”) +(!$.trim($('method',this.text())?“”:“”+”方法:“++$('method',this.text()+”

    ”) +(!$.trim($('clinical_utility',this.text())?“”:“”+“clinical utility:”+$('clinical_utility',this.text()+”

    ')) +“
  • ”); }); } }); });
    搜索后修复了它


    添加了$('#testcatalog')。触发器('create');在代码末尾。

    我用另一种解决方案修复了类似的问题:

    complete: function(){
                              $("#testcatalog").listview();
                              $("#testcatalog").listview('refresh'); 
                             },