问题
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?
回答1:
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/
来源:https://stackoverflow.com/questions/4836562/is-it-posible-to-have-jquery-ui-autocomplete-on-a-contenteditable-div-and-datepi