首页 新闻 搜索 专区 学院

mvc4+jquerymobile,查询按钮click无效,要刷新页面后再点才可以

0
悬赏园豆:20 [已关闭问题] 关闭于 2014-01-24 15:30

代码如下:请大神指点

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title>客户</title>
        <meta name="viewport" content="width=device-width" /> 
        <link href="/favicon.ico" rel="shortcut icon" type="image/x-icon" />
        <link href="/Content/jquery.mobile-1.1.0.css" rel="stylesheet"/>
<link href="/Content/jquery.mobile.structure-1.1.0.css" rel="stylesheet"/>
<link href="/Content/jquery.mobile.theme-1.1.0.css" rel="stylesheet"/>
<link href="/Content/site.css" rel="stylesheet"/>

        <script src="/Scripts/modernizr-2.5.3.js"></script>

        <script src="/Scripts/jquery-1.7.1.js"></script>
<script src="/Scripts/jquery.mobile-1.1.0.js"></script>

          

 <script src="/Scripts/Pager.js"></script>

  <script type="text/javascript">
      $(document).bind("mobileinit", function () {
      });

      $(function () {
          $("body").bind('swiperight', function () {
              $.mobile.changePage("#home", { transition: "slide", reverse: true }, false);
          }).bind('swipeleft', function () {
              $.mobile.changePage("#create", { transition: "slide" }, true);
          });

          $('#btnSearch').live('tap', function () {
              $.mobile.loadingMessageTextVisible = false;
              $.mobile.showPageLoadingMsg();
          });
      });   
      
      
      var query = function (t) {
          $.mobile.showPageLoadingMsg();
          var parames = { page: t, address: $("#txtAddress").val(), name: $("#txtName").val(), mobile: $("#txtMobile").val() };
          var url = "Customers";
          //$("#s").css("collapsed","true");
          GetPagerData(parames, url, query, show);
      }

      var show = function (data) {
          var li = "<ul data-role='listview' data-inset='true'>";
          $.each(data, function (i, item) {
              li += "<li><div>姓名:" + item.shortName + "  <a href='/Customers/Details/" + item.CustID + "'>明细</a></div>" +
                "<div>地址:" + item.Address + "</div></li>";
          });
          li += "</ul>";
          $("#dataList").html(li);
          $("#dataList ul").listview();

          $.mobile.hidePageLoadingMsg();
      }
  </script>
  
  
    </head>
    <body>
        <div data-role="page" data-theme="c">
            <div data-role="header"  data-theme="c">
                    <h1>客户</h1>
<a data-icon="gear" href="/Account">Admin</a><a data-icon="home" href="/">主页</a>            </div> 
            <div data-role="content">
                
 
<p>
    <a href="/Customers/Create">新增</a>
</p>
<div data-role="collapsible" id="s" data-iconpos="right"> 
<h3>查询</h3>
<table>
    <tr>
       <td>姓名</td>
       <td><input type="text" id="txtName" /></td> 
    </tr>
     <tr>
       <td>手机</td>
       <td><input type="text" id="txtMobile" /></td> 
    </tr>
     <tr>
       <td>地址</td>
       <td><input type="text" id="txtAddress" /></td> 
    </tr>
    <tr>
       <td> </td>
       <td><input type="button"  value="查询" id="btnSearch" onclick="query(0)" /></td> 
    </tr>
</table>
</div> 

 <div data-role="content"  id='dataList' >  
  
</div>
<div data-role="footer"  data-theme="e">
 <div > 
     总计 <label id="Records">0</label> 条记录,<label id="PageIndex">0</label> / <label id="TotalPage">0</label></div>   
 <div class="ui-grid-c">
         <a id="first"  class="ui-block-a" href="javascript:void(0)">首页</a>
         <a id="previous"   class="ui-block-b" href="javascript:void(0)"  >上一页</a>
         <a id="next"  class="ui-block-c"  href="javascript:void(0)">下一页</a>
         <a id="last"  class="ui-block-d"  href="javascript:void(0)">末页</a> 
 </div>
 </div>  
 
   
            </div>
        </div>  
     
       
    </body>
</html>
View Code


 

小草原的主页 小草原 | 初学一级 | 园豆:155
提问于:2014-01-24 14:53
< >
分享
所有回答(2)
0

找到原因了,因为使用了 @section Scripts{ ....}方法导致的无法加载绑定事件。

直接在页面里去掉@section Scripts{ }就好了

小草原 | 园豆:155 (初学一级) | 2014-01-24 15:30
0

那里写错了。我这有时候也出现这个问题。

五行缺酒 | 园豆:202 (菜鸟二级) | 2017-01-10 18:56
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册