0

我正在 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"
            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">&nbsp;</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">&nbsp;</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 页,但它会返回到根页面?

为什么会发生这种情况?

谢谢

4

2 回答 2

0

您的内容必须包含在此 div 中:

<div data-role="content" data-theme="a" id="someid"></div>

如果你想要 jQM 页面中的内容,你需要有一个 data-role="content" 。

于 2012-11-28T11:42:05.273 回答
0

我不知道您是否仍在研究此问题或已解决此问题,但我想我会为其他有此问题的人发布解决方案。

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();
        }
    }
});
于 2013-12-17T23:25:35.887 回答