2011-09-20 81 views
1

我正在学习围绕Jquery Mobile的方式,但我在使用jq移动对话框选项确认表单提交时遇到困难。 Wheneven我尝试从我的对话框启动我的runSearch()函数我得到一个“Error Loading Page”消息,如果我直接从srch.asp运行runSearch()函数,页面加载就好了。我正在研究jqmobile的每日构建。确认表单在Jquery Mobile中提交对话框

这是我到目前为止有:

srch.asp:

<!DOCTYPE html> 
<html> 
<head> 
<title>Filter page</title> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/> 
    <link href="http://code.jquery.com/mobile/latest/jquery.mobile.min.css"  rel="stylesheet" type="text/css" /> 
    <script src="http://code.jquery.com/jquery-1.6.2.min.js"></script> 
    <script src="http://code.jquery.com/mobile/latest/jquery.mobile.min.js"></script> 
</head> 
<body > 
<div data-role="page" data-add-back-btn="true" id="main"> 
    <div data-role="header" data-theme="b" data-position="inline">  
    <title>Filter page</title> 
    <script language="JavaScript" type="text/javascript"> 
    var count = 26; 
    function doSearch(){ 
     //var sqlStr = generateSQL(); 
     var sqlStr = 'xxx'; 
     document.getElementById('sqlSrch').value = sqlStr;   
     if (count > 25){ 
      $("#lnkDialog").click(); 
     } 
     else{   
      runSearch(); 
     }    
    } 
    function runSearch(){ 
     $.mobile.changePage("/mobile/famName/results/en", { 
      type: "post", 
      data: $("form#frmSelectors").serialize() 
     });   
    } 
    </script> 
    </div><!-- /header --> 
    <div data-role="content"> 
    <form id='frmSelectors' method="post" action="/mobile/famName/results/en"> 
     <input type="hidden" name="sqlSrch" id="sqlSrch" /> 
     <input type="hidden" name="famID" value="xxx" /> 
     bunch more inputs go here.... 
     <input type="button" value="Search" id='srch' onclick="doSearch()" style="srcButton"/> 
     <a id='lnkDialog' href="#toomany.asp" data-rel="dialog" data-transition="pop"></a> 
    </form> 
    </div><!-- /content -->   
    </div><!-- /page -->  

    </body> 
    </html> 

toomany.asp:

<!DOCTYPE html> 
<html> 
<head> 
<title>Warning</title> 
    <link href="http://code.jquery.com/mobile/latest/jquery.mobile.min.css" rel="stylesheet" type="text/css" /> 
    <script src="http://code.jquery.com/jquery-1.6.2.min.js"></script> 
    <script src="http://code.jquery.com/mobile/latest/jquery.mobile.min.js"></script> 
</head> 
<body> 
<div data-role="dialog" id="dialog"> 
    <div data-role="header"> 
    <h1>Warning</h1> 
    </div>  
    <div data-role="content" data-theme="b"> 
    <div id="text">Error Message</div> 
    <a href="#" data-role="button" data-rel="back" data-transition="slidedown" data-theme="b">Yes</a> 
    <a href="#" onclick="runSearch();" data-role="button" data-rel="dialog" data-transition="slidedown" data-theme="c">No</a> 
    </div> 
</div> 
</body> 
</html> 
+1

尝试加入返回false; runSearch(); –

+0

如果你打算使用jquerymobile,我会建议你更多的使用jquery。它很棒,在你的代码中有一些地方可以派上用场! – Evan

+1

添加返回false;之后runSearch();调用toomany.asp没有解决这个问题,也没有向runSearch函数添加返回false。 –

回答

0

在你srch.asp,你所提供的链接:

<a id='lnkDialog' href="#toomany.asp" data-rel="dialog" data-transition="pop"></a> 

#toomany.asp的链接将连接在同一个页面的锚,但你有一个真正的网页链接,在这里看到的细节: http://jquerymobile.com/demos/1.0b3/docs/pages/page-links.html

您应该使用此链接而不是链接到其他页面的对话框:

<a id='lnkDialog' href="toomany.asp" data-rel="dialog" data-transition="pop"></a> 
0

复制形式@SenadMeškin的评论:

尝试添加返回false; runSearch();

这解决了我正在研究的基于JQMobile的网络应用程序的相同错误。提交表单后,出现“错误加载页面”错误。只需将行return false;添加到正在提交的函数中即可修正错误。虽然这看起来不适用于OP,但Google等人指示的其他人可能会觉得这很有帮助。