我在 jquery mobile(淘汰赛)中遇到重复 ajax 内容的问题。当我调用返回按钮以启动表单以及再次调用所有进程时,问题就开始了。示例代码:
<div data-role="header" data-theme="c">
<a data-bind="click: headerBackBtn" data-role="button">Back</a>
<h1>
Header title
</h1>
</div>
<div data-role="content">
<form id="form" name="form" data-bind="visible: form">
<label for="name">Name:</label>
<input type="search" name="name" id="name"/>
<button data-bind="click: toFirstContent" data-icon="search">Search</button>
</form>
<!-- first content -->
<div class="div-1" id="div-1" data-bind="visible: div-1">
<a data-bind="click: toSecondContent">
Link
</a>
</div>
<!-- second content -->
<div class="div-2" id="div-2" data-bind="visible: div-2">
Text
</div>
</div>
<div data-role="footer" data-theme="c">
<h4>footer</h4>
</div>
self.headerBackBtn = function () {
if (self.div-2()) {
self.div-2(false);
self.div-1(true);
return;
}
if (self.div-1()) {
self.div-1(false);
self.form(true);
return;
}
};