jQuery UI datepicker change event not caught by KnockoutJS

后端 未结 13 2142
长发绾君心
长发绾君心 2020-11-22 16:16

I\'m trying to use KnockoutJS with jQuery UI. I have an input element with a datepicker attached. I\'m currently running knockout.debug.1.2.1.js and it seems th

相关标签:
13条回答
  • 2020-11-22 16:43

    Thanks for this article I found it very useful.

    If you want the DatePicker to behave exactly like the JQuery UI default behaviour I recommend adding a blur on the element in the change event handler:

    i.e.

        //handle the field changing
        ko.utils.registerEventHandler(element, "change", function () {
            var observable = valueAccessor();
            observable($(element).datepicker("getDate"));
    
            $(element).blur();
    
        });
    
    0 讨论(0)
提交回复
热议问题