在内容可编辑的div和datepicker上协调工作时,让jQuery UI自动完成是否可行? [英] Is it posible to have jQuery UI autocomplete on a contenteditable div and datepicker working in harmony?
问题描述
在论坛帖子中我们看到了如何在内容可编辑的div上实现自动完成元素,但是与datepicker结合使用时,datepicker根本不会填充输入字段.
您可以在此jsFiddle演示中看到: http://jsfiddle.net/xvnaA/ >
有人对如何解决此问题有任何明智的想法吗?
您可以像这样重新定义它,而不是仅覆盖$.fn.val
:
(function ($) {
var original = $.fn.val;
$.fn.val = function() {
if ($(this).is('[contenteditable]')) {
return $.fn.text.apply(this, arguments);
};
return original.apply(this, arguments);
};
})(jQuery);
请参见 http://jsfiddle.net/xvnaA/27/
In the forum post "How to make jquery autocomplete to work for a contenteditable DIV instead of just INPUT, TEXTAREA fields." we see how to get autocomplete working on a contenteditable div element, however combined with datepicker the datepicker simply does not populate the input field.
As you can see in this jsFiddle demo: http://jsfiddle.net/xvnaA/
Anyone have any wise ideas on how to fix this?
Instead of just overriding $.fn.val
you could redefine it like this:
(function ($) {
var original = $.fn.val;
$.fn.val = function() {
if ($(this).is('[contenteditable]')) {
return $.fn.text.apply(this, arguments);
};
return original.apply(this, arguments);
};
})(jQuery);
See http://jsfiddle.net/xvnaA/27/
这篇关于在内容可编辑的div和datepicker上协调工作时,让jQuery UI自动完成是否可行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!