0

我有一个页面,它在从外部 php 文件获取列表后创建一个列表视图。当我单击页面上的按钮(打开一个对话框),然后关闭对话框时,列表消失了我该如何解决...

HTML //带有列表视图的页面

<div data-role="header" data-position="fixed">
    <h1>Menu</h1>
</div>
<div data-role="content">
    <div data-role="controlgroup" data-mini="true" align="right" data-type="horizontal">
        <a href="#create" data-role="button" data-icon="gear" data-inline="true" data-theme="b" data-rel="dialog">
            Create
        </a>
        <a href="#join" data-role="button" data-icon="plus" data-inline="true" data-theme="b" data-rel="dialog">
            Join
        </a>
    </div>
    <ul data-role="listview" id="ccontent" data-inset="true">

    </ul>
</div>

</div>

HTML //带有输入的页面(对话框)

<div data-role="page" id="create">
<div data-role="header">
    <h1>Create</h1>
</div>
<div data-role="content">
    <form id="name" align="left">
        <label for="name">Name:</label>
        <input type="text" id="name" name="name" value=""/>
        <input type="submit" value="Submit" data-inline="true">
    </form>


    <div id="result" style="visibility: hidden"></div>
</div>
</div>

JAVASCRIPT //输入提交后

$("#name").submit(function (e) {
e.preventDefault();
$.ajax({
url: 'some url',
crossDomain: true,
type: 'post',
data: $("#name").serialize(),
success: function (data) {
$("#result").html(data);
$('#ccontent').listview('refresh');
},
});
});

JAVASCRIPT //从外部来源获取信息以制作列表

function getClubs() {
$.ajax({
url: 'some url',
crossDomain: true,
type: 'post',
data: '',
success: function (data) {
$('#ccontent').empty();
var json = jQuery.parseJSON(data);
for (var i = 0; i < json.length; i++)
$('#ccontent').append('<li><a href="#" data-club-id=\"' + json[i].id + '\" rel="external">' + json[i].name + '</a></li>');
$('#ccontent').listview('refresh');
},
});
}

JAVASCRIPT //调用getclubs

$('#page-tasklist').ready(function() {
    getClubs();
});
4

0 回答 0