Datepicker单击事件未触发 [英] Datepicker click event not firing

查看:65
本文介绍了Datepicker单击事件未触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个简短的问题,我无法解决问题.

A quick question that I can't wrap my head around.

我们有一个简单的Datepicker(jQuery UI),在td上有一个click事件,仅此而已.但是,无论我如何尝试,点击事件都不会触发.

We have a simple Datepicker (jQuery UI) with a click event on the td and nothing else. But no matter what I try the click event will not fire.

示例: https://jsfiddle.net/s63y1w6h/

单击事件被延迟,因为每次单击td时html都会更改,但是相同的无"再次发生.

The click event is delaged, since the html changes each time a td is clicked, but the same "nothing" happens again.

关于为什么需要单击a的原因,我需要td数据属性,文本及其功能,这将很难通过onSelect method获得.

As to why I need to click the a, I need the td data attributes, text and its offeset, which will be harder to get from the onSelect method.

是否知道如何触发点击事件?

Any idea how to fire up the click event?

推荐答案

点击一天后,您仍然可以使用onSelect触发逻辑

You can still use onSelect to fire your logic when a day is clicked

$('.datepicker').datepicker({
  onSelect:function(dt,obj){
    var day = parseInt(dt.substring(3,5));
    var td;
    $("td>a").each(function(index,elm){
     if(parseInt($(elm).html()) === day){
       td = $(elm).parent();
       return;
      }
    })
    console.log(td)
    alert("You're welcome!!!")
  }
});

编写了一些骇客逻辑,以便根据所选日期获得td

Wrote some hack logic to get the td based on the day selected

工作 plnkr

这篇关于Datepicker单击事件未触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆