材质datepicker中的奇怪行为 [英] Strange behaviour in Material datepicker

查看:121
本文介绍了材质datepicker中的奇怪行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Google的实用日期选择器( http://materializecss.com/forms.html)。这样,当我点击一个图标时,我想弹出日期选择器。我已经实现了两个实现,两者之间的唯一区别是使用代码将 alert('clicked')

I'm trying to use google's materialize date picker (http://materializecss.com/forms.html). With that, I want to popup the date picker when I click on an icon. I have implemented two implementations where the only difference between the two is putting an alert('clicked') with the code.

没有 alert('clicked') http://jsfiddle.net/1bnnkhbw/

alert('clicked') http: //jsfiddle.net/1bnnkhbw/1/

第二个工作,而第一个没有..(在chrome)! !!

有人知道这个行为的原因吗?

Anybody knows the reason for this behavior?

还有一种使第一个工作的方法?

And a way to make the 1st one work?

推荐答案

我想我找到一个解决方案,你们检查一下:

I think I found a solution for you man check this out:

<i id="icon">click</i>
<input class="datepicker" style="display:none;" value="click"></input>



$('.datepicker').pickadate({
    selectMonths: true,
    selectYears: 15 
  });

$('#icon').click(function(event){
    event.stopPropagation();
    $(".datepicker").first().pickadate("picker").open();
    console.log("test1");
});

小提琴: http://jsfiddle.net/k2qtzp7p/1/

这里这里

这篇关于材质datepicker中的奇怪行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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