Is it posible to have jQuery UI autocomplete on a contenteditable div and datepicker working in harmony?

风流意气都作罢 提交于 2019-12-22 10:08:00

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!