Jquery mobile jQuery移动提交表单将我返回主页,而不是下一页
我正在jQuery mobile中构建一个小应用程序 我在提交表格时从一页转到另一页时遇到问题 所以我的第一页看起来像这样Jquery mobile jQuery移动提交表单将我返回主页,而不是下一页,jquery-mobile,Jquery Mobile,我正在jQuery mobile中构建一个小应用程序 我在提交表格时从一页转到另一页时遇到问题 所以我的第一页看起来像这样 <div data-role="page" data-theme="a" id="page1"> <div data-role="header" data-theme="a"> <h1>Contact Us</h1> <a data-icon="back" d
<div data-role="page" data-theme="a" id="page1">
<div data-role="header" data-theme="a">
<h1>Contact Us</h1>
<a data-icon="back"
data-iconpos="notext"
data-rel="back"
data-transition="slidefade"
>Info</a>
<a href="#home"
data-icon="home"
data-iconpos="notext"
data-transition="slidefade"
>Home</a>
</div>
<div class="pageContainer">
<section id="links">
<form name="page1" method="post" action="#page2" id="form">
<div class="panel colourPanel">
<div class="searchMethod buttonColour even">
<input name="hidBranch" type="hidden" id="hidBranch" value="0" />
<div class="searchText textShadow">Branch</div>
<div class="searchImg"> </div>
</div>
<div class="searchMethod buttonColour odd">
<input name="hidATM" type="hidden" id="hidATM" value="0" />
<div class="searchText textShadow">ATM</div>
<div class="searchImg"> </div>
</div>
<div class="searchInput">
<input id="searchArea" type="text" value="Search address">
</div>
<div id="searchContainer">
<input type="submit" name="btnSearch" id="btnSearch2" alt="Find" value="Search" />
</div>
</div>
</form>
</section>
</div>
联系我们
分支机构
自动取款机
所以我希望这会转到第2页,但它会返回到根页面
为什么会发生这种情况
谢谢您的内容必须包装在此div中:
<div data-role="content" data-theme="a" id="someid"></div>
如果您想在jQM页面中添加内容,您需要一个data role=“content”。我不知道您是否仍在处理此问题或已解决此问题,但我想我会为其他人发布解决此问题的方法 jQM默认在表单提交后将应用程序返回到“第一页”。您可以使用以下命令(取自)更改默认值。jQM正在侦听对
pagebeforechange
事件的调用,以在处理表单和导航时更新默认值
// Listen for any attempts to call changePage().
$(document).bind( "pagebeforechange", function( e, data ) {
// We only want to handle changePage() calls where the caller is
// asking us to load a page by URL.
if ( typeof data.toPage === "string" ) {
// We are being asked to load a page by URL, but we only
// want to handle URLs that request the data for a specific
// category.
var u = $.mobile.path.parseUrl( data.toPage ),
re = /^#category-item/;
if ( u.hash.search(re) !== -1 ) {
// We're being asked to display the items for a specific category.
// Call our internal method that builds the content for the category
// on the fly based on our in-memory category data structure.
showCategory( u, data.options );
// Make sure to tell changePage() we've handled this call so it doesn't
// have to do anything.
e.preventDefault();
}
}
});
即使有了那个div,它也不会进入下一页。它会将#page2添加到url,但不会转到下一页。您的HTML是否缺少另一页<代码>