jQuery Mobile multi-page swipe (MVC4, #C, .NET)

jQuery Mobile multi-page swipe (MVC4, #C, .NET)

Hi, i am trying to display my model values in several different jQuery mobile pages.
But when i use my code only 1 page is rendered in the source code, 
wye? &  how do i fix it ?

  1. My ID's of pages are unique.
  2. My data-role="page" contains sections: header, content, footer.
  3. My model thats loops contains more than 1 row.

This is my View:
  1. @model List<itsperfect.Extreme.Web.Booking.Models.BookingDays>

  2. @{
  3.     ViewBag.Title = "Välj din tid";
  4.     Layout = "~/Views/Shared/_MobileSwipe.Mobile.cshtml";
  5. }

  6. <input type="hidden" id="SearchDate" value="@ViewBag.FirstAvalibleDate" />

  7. <div id="swipeDiv">
  8.     @for (int i = 0; i < Model.Count(); i++)
  9.     {
  10.         var display = Model[i];
  11.         <div data-role="page" id="@display.inputDate.ToString("yyyyMMdd")" data-title="Boka tid @display.inputDate.ToString("yyyyMMdd")">
  12.             <div data-role="header">
  13.                 <div class="header-text">
  14.                     <h4>
  15.                         @display.inputDate.ToString("dddd 'den' d MMMM yyyy")
  16.                     </h4>
  17.                 </div>
  18.             </div>

  19.             <div data-role="content">
  20.                 <ul data-role="listview">
  21.                     @if (display.Times != null)
  22.                     {
  23.                         foreach (var t in display.Times.OrderBy(x => x.startDate))
  24.                         {
  25.                         <li>
  26.                             <a href="#" class="k-button" onclick="javascript:Forhandsvisning(@display.LocationID , @t.ResourceID,'@string.Join(";", t.ServiceID)','@string.Format("{0:yyyy-MM-dd HH:mm}", t.startDate)','@string.Format("{0:yyyy-MM-dd HH:mm}", t.endDate)',@t.UserResourceID)">@String.Format("{0}-{1}", string.Format("{0:HH:mm}", t.startDate), string.Format("{0:HH:mm}", t.endDate))</a>
  27.                         </li>
  28.                         }
  29.                         if (display.inputDate < DateTime.Now.Date)
  30.                         {
  31.                         <li>Datum har passerat</li>
  32.                         }
  33.                         if (display.Times.Count == 0 && display.inputDate >= DateTime.Now.Date)
  34.                         {
  35.                         <li>Inga lediga tider</li>
  36.                         }
  37.                     }
  38.                     else
  39.                     {
  40.                         if (display.WeekNo == 0)
  41.                         {
  42.                             // Scedual missing
  43.                             <li>Inga lediga tider</li>
  44.                         }
  45.                     }
  46.                 </ul>
  47.             </div>
  48.             <div data-role="footer"></div>
  49.         </div>
  50.        
  51.     }
  52. </div>

  53. <script>
  54.     $('#swipeDiv').live("swipeleft", function () {
  55.         var nextpage = $(this).next('div[data-role="page"]');
  56.         // swipe using id of next page if exists
  57.         if (nextpage.length > 0) {
  58.             $.mobile.changePage(nextpage, 'slide');
  59.         }
  60.     });
  61.     $('#swipeDiv').live("swiperight", function () {
  62.         var prevpage = $(this).prev('div[data-role="page"]');
  63.         // swipe using id of next page if exists
  64.         if (prevpage.length > 0) {
  65.             $.mobile.changePage(prevpage, 'slide', true);
  66.         }
  67.     });
  68. </script>
This is my Layout:
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <meta name="viewport" content="width=device-width">
  5.     <meta charset="utf-8" />
  6.     <title>@ViewBag.Title </title>
  7.     @Html.MetaAcceptLanguage()
  8.     <script src="@Url.Content("~/Scripts/kendo/2012.3.1121/jquery.min.js")"></script>
  9.     @Scripts.Render("~/bundles/jquerymobile")
  10.     @Styles.Render("~/Content/Mobile/css")
  11.     @Styles.Render("~/Content/jquerymobile/css")
  12. </head>
  13. <body>
  14.     @RenderBody()
  15. </body>
  16. </html>


  17. <script>
  18.       // If i dont use this, old layout getting cached.
  19.     $(document).ready(function () {
  20.         $.ajaxSetup({ cache: false });
  21.     });
  22. </script>
This is how my source code looks like:

  1. <html class="ui-mobile"><head><base href="http://localhost:50491/84802137/Boka/SearchMobile">
  2.     <meta name="viewport" content="width=device-width,maximum-scale=10, user-scalable=yes">
  3.     <meta charset="utf-8">
  4.     <title>Boka tid 20130220</title>
  5.     <meta name="accept-language" content="sv-SE">

  6.     <script src="/Scripts/kendo/2012.3.1121/jquery.min.js"></script>
  7.     <script src="/Scripts/mobile/jquery.mobile-1.2.0.min.js" type="text/javascript"></script>

  8.     <link href="/Content/Site.Mobile.css" rel="stylesheet" type="text/css">

  9.     <link href="/Content/mobile/jquery.mobile-1.2.0.min.css" rel="stylesheet" type="text/css">

  10.     <link href="/favicon.ico" rel="shortcut icon" type="image/x-icon">
  11. <style id="css-ddslick" type="text/css">.dd-select{ border-radius:2px; border:solid 1px #ccc; position:relative; cursor:pointer; }.dd-desc { color:#aaa; display:block; overflow: hidden; font-weight:normal; line-height: 1.4em; }.dd-selected{ overflow:hidden; display:block; padding:10px; font-weight:bold;}.dd-pointer{ width:0; height:0; position:absolute; right:10px; top:50%; margin-top:-3px;}.dd-pointer-down{ border:solid 5px transparent; border-top:solid 5px #000; }.dd-pointer-up{border:solid 5px transparent !important; border-bottom:solid 5px #000 !important; margin-top:-8px;}.dd-options{ border:solid 1px #ccc; border-top:none; list-style:none; box-shadow:0px 1px 5px #ddd; display:none; position:absolute; z-index:2000; margin:0; padding:0;background:#fff; overflow:scroll; }.dd-option{ padding:10px; display:block; border-bottom:solid 1px #ddd; overflow:hidden; text-decoration:none; color:#333; cursor:pointer;-webkit-transition: all 0.25s ease-in-out; -moz-transition: all 0.25s ease-in-out;-o-transition: all 0.25s ease-in-out;-ms-transition: all 0.25s ease-in-out; }.dd-options > li:last-child > .dd-option{ border-bottom:none;}.dd-option:hover{ background:#f3f3f3; color:#000;}.dd-selected-description-truncated { text-overflow: ellipsis; white-space:nowrap; }.dd-option-priority { float:left; margin: 4px 12px 0px 0px; }.dd-option-selected { background:#f6f6f6; }.dd-option-image, .dd-selected-image { vertical-align:middle; float:left; margin-right:5px; max-width:64px; z-index: 5000;}.dd-image-right { float:right; margin-right:15px; margin-left:5px;}.dd-container{ position:relative;}​ .dd-selected-text { font-weight:bold}​</style></head>
  12. <body class="ui-mobile-viewport ui-overlay-c">
  13.     
  14.     <div class="ui-loader ui-corner-all ui-body-a ui-loader-default"><span class="ui-icon ui-icon-loading"></span><h1>loading</h1></div><div data-role="page" id="20130220" data-title="Boka tid 20130220" data-url="/84802137/Boka/SearchMobile" data-external-page="true" tabindex="0" class="ui-page ui-body-c ui-page-active" style="min-height: 480px;">
  15.             <div data-role="header" class="ui-header ui-bar-a" role="banner">
  16.                 <div class="header-text">
  17.                     <h4>
  18.                         onsdag den 20 februari 2013
  19.                     </h4>
  20.                 </div>
  21.             </div>

  22.             <div data-role="content" class="ui-content" role="main">
  23.                 <ul data-role="listview" class="ui-listview">
  24.                         <li data-corners="false" data-shadow="false" data-iconshadow="true" data-wrapperels="div" data-icon="arrow-r" data-iconpos="right" data-theme="c" class="ui-btn ui-btn-icon-right ui-li-has-arrow ui-li ui-btn-up-c"><div class="ui-btn-inner ui-li"><div class="ui-btn-text">
  25.                             <a href="#" class="k-button ui-link-inherit" onclick="javascript:Forhandsvisning(1 , 26,'2005','2013-02-20 09:00','2013-02-20 10:00',26)">09:00-10:00</a>
  26.                         </div><span class="ui-icon ui-icon-arrow-r ui-icon-shadow">&nbsp;</span></div></li>
  27.                         <li data-corners="false" data-shadow="false" data-iconshadow="true" data-wrapperels="div" data-icon="arrow-r" data-iconpos="right" data-theme="c" class="ui-btn ui-btn-icon-right ui-li-has-arrow ui-li ui-btn-up-c"><div class="ui-btn-inner ui-li"><div class="ui-btn-text">
  28.                             <a href="#" class="k-button ui-link-inherit" onclick="javascript:Forhandsvisning(1 , 26,'2005','2013-02-20 10:00','2013-02-20 11:00',26)">10:00-11:00</a>
  29.                         </div><span class="ui-icon ui-icon-arrow-r ui-icon-shadow">&nbsp;</span></div></li>
  30.                         <li data-corners="false" data-shadow="false" data-iconshadow="true" data-wrapperels="div" data-icon="arrow-r" data-iconpos="right" data-theme="c" class="ui-btn ui-btn-icon-right ui-li-has-arrow ui-li ui-btn-up-c"><div class="ui-btn-inner ui-li"><div class="ui-btn-text">
  31.                             <a href="#" class="k-button ui-link-inherit" onclick="javascript:Forhandsvisning(1 , 26,'2005','2013-02-20 11:00','2013-02-20 12:00',26)">11:00-12:00</a>
  32.                         </div><span class="ui-icon ui-icon-arrow-r ui-icon-shadow">&nbsp;</span></div></li>
  33.                         <li data-corners="false" data-shadow="false" data-iconshadow="true" data-wrapperels="div" data-icon="arrow-r" data-iconpos="right" data-theme="c" class="ui-btn ui-btn-icon-right ui-li-has-arrow ui-li ui-btn-up-c"><div class="ui-btn-inner ui-li"><div class="ui-btn-text">
  34.                             <a href="#" class="k-button ui-link-inherit" onclick="javascript:Forhandsvisning(1 , 26,'2005','2013-02-20 12:00','2013-02-20 13:00',26)">12:00-13:00</a>
  35.                         </div><span class="ui-icon ui-icon-arrow-r ui-icon-shadow">&nbsp;</span></div></li>
  36.                         <li data-corners="false" data-shadow="false" data-iconshadow="true" data-wrapperels="div" data-icon="arrow-r" data-iconpos="right" data-theme="c" class="ui-btn ui-btn-icon-right ui-li-has-arrow ui-li ui-btn-up-c"><div class="ui-btn-inner ui-li"><div class="ui-btn-text">
  37.                             <a href="#" class="k-button ui-link-inherit" onclick="javascript:Forhandsvisning(1 , 26,'2005','2013-02-20 13:00','2013-02-20 14:00',26)">13:00-14:00</a>
  38.                         </div><span class="ui-icon ui-icon-arrow-r ui-icon-shadow">&nbsp;</span></div></li>
  39.                         <li data-corners="false" data-shadow="false" data-iconshadow="true" data-wrapperels="div" data-icon="arrow-r" data-iconpos="right" data-theme="c" class="ui-btn ui-btn-icon-right ui-li-has-arrow ui-li ui-btn-up-c"><div class="ui-btn-inner ui-li"><div class="ui-btn-text">
  40.                             <a href="#" class="k-button ui-link-inherit" onclick="javascript:Forhandsvisning(1 , 26,'2005','2013-02-20 14:00','2013-02-20 15:00',26)">14:00-15:00</a>
  41.                         </div><span class="ui-icon ui-icon-arrow-r ui-icon-shadow">&nbsp;</span></div></li>
  42.                         <li data-corners="false" data-shadow="false" data-iconshadow="true" data-wrapperels="div" data-icon="arrow-r" data-iconpos="right" data-theme="c" class="ui-btn ui-btn-icon-right ui-li-has-arrow ui-li ui-btn-up-c"><div class="ui-btn-inner ui-li"><div class="ui-btn-text">
  43.                             <a href="#" class="k-button ui-link-inherit" onclick="javascript:Forhandsvisning(1 , 26,'2005','2013-02-20 15:00','2013-02-20 16:00',26)">15:00-16:00</a>
  44.                         </div><span class="ui-icon ui-icon-arrow-r ui-icon-shadow">&nbsp;</span></div></li>
  45.                         <li data-corners="false" data-shadow="false" data-iconshadow="true" data-wrapperels="div" data-icon="arrow-r" data-iconpos="right" data-theme="c" class="ui-btn ui-btn-icon-right ui-li-has-arrow ui-li ui-li-last ui-btn-up-c"><div class="ui-btn-inner ui-li"><div class="ui-btn-text">
  46.                             <a href="#" class="k-button ui-link-inherit" onclick="javascript:Forhandsvisning(1 , 26,'2005','2013-02-20 16:00','2013-02-20 17:00',26)">16:00-17:00</a>
  47.                         </div><span class="ui-icon ui-icon-arrow-r ui-icon-shadow">&nbsp;</span></div></li>
  48.                     
  49.                 </ul>
  50.             </div>
  51.             <div data-role="footer" class="ui-footer ui-bar-a" role="contentinfo"></div>
  52.         </div></body></html>