jQuery UI datepicker change event not caught by KnockoutJS

后端 未结 13 2463
长发绾君心
长发绾君心 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:38

    Alternatively, you can specify this in binding:

    Update:

     function (element, valueAccessor) {
        var value = ko.utils.unwrapObservable(valueAccessor()),
            current = $(element).datepicker("getDate");
    
        if (typeof value === "string") {            
           var dateValue = new Date(value);
           if (dateValue - current !== 0)
               $(element).datepicker("setDate", dateValue);
        }               
    }
    

提交回复
热议问题