我有一个奇怪的问题。当我将带有 datepicker 类的输入放入 fyncybox 包装中时,当我单击该输入时,datepicker 不会显示。
<a href="#test" class="fancybox">Open</a>
<div id="test" style="display:none;width:300px;">
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque blandit, mi sed
</p>
<input type="text" class="datepicker"/>
</div>
$(".datepicker").datepicker();
$(".fancybox").fancybox({
openEffect : 'none',
closeEffect : 'none',
afterLoad : function() {
this.inner.prepend( '<h1>1. My custom title</h1>' );
this.content = '<h1>2. My custom title</h1>' + this.content.html();
}
});
查看此example在 fiddle 上。
提前致谢;-)
最佳答案
嗨,我最终找到了这两个解决方案:
首先: fiddle of first solution here
$(document).on('click', '.datepicker', function(){
if (!$(this).hasClass('hasDatepicker')) {
$(this).datepicker(); $(this).datepicker('show');
}
});
$(".fancybox").fancybox({
openEffect : 'none',
closeEffect : 'none',
afterLoad : function() {
this.inner.prepend( '<h1>1. My custom title</h1>' );
this.content = '<h1>2. My custom title</h1>'+ this.content.html();
}
});
第二: fiddle of second solution here
$(".datepicker").datepicker();
$(".fancybox").fancybox({
openEffect : 'none',
closeEffect : 'none'
});
关于jquery-ui - fancybox 中的 jqueryUI datepicker 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18574886/