2013-09-01 86 views
1

嗨大家我創建了一個使用jquery的datepicker的mvc應用程序。例如,當我點擊一個特定的日期時,相應的事件將顯示爲列表。下面的代碼片段工作正常,但是當我跑使用Opera移動模擬器的同一頁面的點擊事件沒有被觸發。Jquery Mobile datepicker事件不起作用

jquery: 
jquery-ui-1.8.20.custom.css 

Note:I used the following link as reference 

http://www.hongkiat.com/blog/jquery-ui-datepicker/ 

If anyone give the solution,it ll great helpful to me. 

@model IEnumerable<WazUpDataServicesMVC4.Model.EventViewModel> 

@{ 
ViewBag.Title = "Calendar"; 
    } 

@section Header 
    { 
<a href="@Url.Action("Index", "Events")" data-icon="back" class="ui-btn- left">Events</a> 
<h1>@ViewBag.Title</h1> 



<link href="@(Url.Content("~/Content/datepicker.css"))" rel="stylesheet" type="text/css" /> 

$(function() { 
     $('#datepicker').datepicker({ 
      inline: true, 
      //nextText: '&rarr;', 
      //prevText: '&larr;', 
      showOtherMonths: true, 
      //dateFormat: 'dd MM yy', 
      dayNamesMin: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], 
      onSelect: function (date, obj) { 
       if (date) { 
        $("#listLayers").find("a:[data-date!='" + date + "']").parent().parent().parent().slideUp(); 
        $("#listLayers").find("a:[data-date='" + date + "']").parent().parent().parent().slideDown(); 
       } else { 
        $("#listLayers").find("a").parent().parent().parent().slideDown(); 
       } 
      } 

     }); 

    }); 
</script> 

}

<div id="datepicker"></div> 

    <ul data-role="listview" data-inset="true" id="listLayers"> 


    @foreach (var item in Model) 


    { 
    string display = "none"; 

    if (DateTime.Now.ToString("MM/dd/yyyy") == item.DateEventTo.ToString("MM/dd/yyyy")) 
    { 
     display = "block"; 
    } 


     <li style="display:@(display);"> 

      <a data-date="@(item.DateEventTo.ToString("MM/dd/yyyy"))" class="calendar-link" href="@Url.Action("Events", "Events", new { id = item.EventID,description=item.Description })"> 
      @item.Description 
      </a> 

     </li> 


    } 
</ul> 

回答

0

你的問題是最有可能的jQuery移動已經用於從瀏覽器無論您已經在測試,它是工作的歌劇不同的標記。我會建議更改行

if (date) { 
    $("#listLayers").find("a:[data-date!='" + date + "']").parent().parent().parent().slideUp(); 
    $("#listLayers").find("a:[data-date='" + date + "']").parent().parent().parent().slideDown(); 
} else { 
    $("#listLayers").find("a").parent().parent().parent().slideDown(); 
} 

要使用closest()函數。如果你知道什麼元素$("#listLayers").find("a").parent().parent().parent().slideDown();應該是,例如它是一個div或有一個類或一些其他已知的標識符,你可以使用$("#listLayers").find("a").closest('div')