1

我正在使用 Visual Studio 中的 jquery 移动模板。在我的布局视图中,我有以下标记

   <div data-role="page"  @(Page.Id == null ? string.Empty : "id=" + Page.Id) data-fullscreen="false">

当我的浏览视图呈现时,我想将数据全屏属性更改为 true。这是我试图用来执行此操作的代码..

<script type="text/javascript">
  $("#indexPage").live('pageinit', function () {
            alert("Code Engaged");
            $("#div").attr("data-fullscreen", "true");
        });
</script>

我无法使用此代码。我在哪里放置代码来参与它?布局有几个部分..

<head>
  <meta charset="utf-8" />

  <!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame 
       Remove this if you use the .htaccess -->
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

  <title>@Page.Title</title>
  <meta name="description" content="jQuery Mobile Site">
  <meta name="author" content="">

  <!--  Mobile viewport optimized: j.mp/bplateviewport -->
  @*<meta name="viewport" content="width=device-width, initial-scale=1.0">*@
  <meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1">


  <!-- jQuery Mobile Latest Styles -->
  <link rel="stylesheet" href="//code.jquery.com/mobile/latest/jquery.mobile.min.css" />

  @* // reference the minified version of our combined css based on whether we are in debug mode. *@
  @if (jQueryMobileTemplate.MvcApplication.IsDebug)
  { 
   @* <link rel="stylesheet" href="@Url.Content("~/css/style.css?v=2")" />*@
     <link rel="stylesheet" href="@Url.Content("~/css/custom%20themes/electric1.css?v=2")" /> 

  }
  else
  {
   @* <link rel="stylesheet" href="@Url.Content("~/css/style.min.css?v=2")" />*@
       <link rel="stylesheet" href="@Url.Content("~/css/custom%20themes/electric1.min.css?v=2")" />


  }

  <!-- Grab Google CDN's jQuery. fall back to local if necessary -->
  <!-- We put these at the top because jquery mobile applies styles before the page finishes loading -->
  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js">


  </script>
  <script>      window.jQuery || document.write("<script src='@Url.Content("~/js/libs/jquery-1.6.1.min.js")'>\x3C/script>")</script>

  <!-- Pre jQuery Mobile init scripts for overriding defaults -->
  <script>

  </script>

  <!-- Load jQuery Mobile from jquery cdn, get latest builds -->
  <script src="//code.jquery.com/mobile/latest/jquery.mobile.min.js">

  </script>
  @* <!-- Optionally, load from local site -->
    <script src="@Url.Content("~/js/libs/jquery.mobile-1.0b1.js")"></script>
  *@

  @RenderSection("HeadContent", false)

  @*<script src="@Url.Content("~/js/libs/modernizr-2.0.min.js")"></script>
  <script src="@Url.Content("~/js/libs/respond.min.js")"></script>*@


</head>

我也在“浏览”视图的底部尝试过,但没有。我只希望“浏览”视图执行此代码。

4

1 回答 1

0

pageinit当我使用 asp.net-mvc 时,由于某种原因,该事件也从未对我正常工作。您可以尝试改用其中一个页面更改事件(pagebeforechangepagechange)。

于 2012-07-26T13:42:45.143 回答