I am loading a list view inside a collapsible from the server (php file) via a GET response message. However, jQuery formatting is not being applied to the added HTML despite refreshing the jQuery element

我正在通过GET响应消息从服务器(php文件)加载可折叠的列表视图。但是,尽管刷新了jQuery元素,但jQuery格式化并未应用于添加的HTML

My page is here : http://i.cs.hku.hk/~hsbashir/Project_Work/events/events.html

我的页面在这里:http://i.cs.hku.hk/~hsbashir/Project_Work/events/events.html

HTML Code (relevant code only)

HTML代码(仅限相关代码)

<script>
lastRecord=0;

    function loadEvents(){

        $('#sample').html( 'hello' );
        $.get(
        "eventquery.php?lastRecord="+lastRecord,
        function( data ) {
            $('#loadCollapsible').append( data )
            .listview( 'refresh' );
            }); 

    }
</script>
</head>
<body style="background-color : #e9e9e9;" onload="loadEvents()">

<div data-iconpos="none" data-role="collapsibleset" data-theme="a" data-content-theme="a">

<div data-role="collapsible" data-collapsed="false">
    <h2><img src="today_calendar.png" style="height: 60px; vertical-align:middle;"> Today's Events </h2>
    <div id="loadCollapsible">
    <!-- Load from php -->
    </div>
</div>  

PHP Code (relevant code only)

PHP代码(仅限相关代码)

    while ($row = mysql_fetch_array($result)){

        print '<div data-role="collapsible" data-collapsed="false">';

        print '<h5>'.$row['Title'].'<h5>';
        print ' <ul data-role="listview">';
        print '<li><a href="#">';
        print '<table><tr><td>Date</td>';
        print '<td style="padding: 10px;">'.$row['Date'].'</td>';
        print '</tr><tr>';
        print '<td> Time </td>';
        print '<td style="padding: 10px;">'.$row['Time_Duration'].'</td>';
        print '</tr><tr>';
        print '<td> Venue </td>';
        print '<td style="padding: 10px;">'.$row['Venue'].'</td>';
        print '</tr></table></a></li>';
        print '<li style="background-color: #CADECC;">';
        print '<button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-calendar" style="width: 170px; float: right; position: relative;">Add to calendar</button>';
        print '</li></ul>'; 

        print '</div>';
    }

2 个解决方案

#1


1

jQuery Mobile listview must first be initialized before calling the refresh method.

首先必须在调用refresh方法之前初始化jQuery Mobile listview。

Because you're loading the list with ajax it doesn't get initialized automatically. Try this:

因为您正在使用ajax加载列表,所以它不会自动初始化。试试这个:

function loadEvents(){

        $('#sample').html( 'hello' );
        $.get(
        "eventquery.php?lastRecord="+lastRecord,
        function( data ) {
            $('#loadCollapsible').append( data );
            $('#loadCollapsible ul').listview().listview( 'refresh' );
            }); 

    }

更多相关文章

  1. Server.Htmlencode用于文本域显示带的html代码
  2. IOS学习之WebView加载本地HTML代码或网络资源
  3. html5 css3 背景视频循环播放代码
  4. HTML5 标签audio添加网页背景音乐代码
  5. 我无法理解为什么我的代码中的单击选择文本
  6. js字符串与html代码互相转换时怪想法:自己解析js字符串成普通字
  7. 解决FCKEditor编辑器在浏览器返回时显示html源代码的问题
  8. 高分求:如何解析IdHTTP获得的http代码?用mshttp的IHTMLDocument2可
  9. 韩顺平_轻松搞定网页设计(html+css+javascript)_第19讲_js运行原

随机推荐

  1. eclipse android开发环境 bug CDT包含路
  2. 一起学android之给图片添加涂鸦(文字)(37)
  3. Android---2---TextView、Button、EditTe
  4. Android中的android:layout_width和andro
  5. Android菜鸟之路-多线程下载
  6. android中九宫格布局的实现
  7. Android(安卓)studio真的很坑啊,智能还很
  8. android的PowerManager和PowerManager.Wa
  9. Android单元测试 Instrumentation
  10. android View各属性详解