【问题标题】:Jquery Mobile datepicker event not workingJquery Mobile datepicker 事件不起作用
【发布时间】:2013-09-01 04:41:10
【问题描述】:

大家好,我使用 jquery 创建了一个带有 datepicker 的 mvc 应用程序。例如,当我单击特定日期时,该日期上的相应事件将显示为列表。以下代码 sn-p 工作正常,但是当我使用运行同一页面时Opera 移动模拟器点击事件未触发。

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>

【问题讨论】:

    标签: javascript jquery html css datepicker


    【解决方案1】:

    您的问题很可能是 jQuery mobile 使用了与您测试过的任何浏览器不同的 Opera 标记并且它正在工作。建议换行

    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')

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-07
      • 2013-06-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多