Knockout.js with jquery ui datepicker works everywhere except IE

前端 未结 2 2019
南旧
南旧 2021-01-20 17:16

I used a knockout.js templatescript to create a form that can be duplicated and deleted. The fiddle can be found here.

I editted the script with a litle help from SE

相关标签:
2条回答
  • 2021-01-20 17:47

    2 things:

    like I said in the comments, use window.console.log (or a wrapper function) instead of console.log to prevent errors on older browsers who don't know the console object.

    I use this (and many others) to autocorrect a field. In this case uppercase the input. This works excellent on the first form. But not on any duplicate forms.

    replace:

    $(".hoofdletters").keyup(function(e) { $(".hoofdletters").val(($(".hoofdletters").val()).toUpperCase()); });
    

    with :

    $(".hoofdletters").on('keyup', '#<some root element>', function(e) { $(".hoofdletters").val(($(".hoofdletters").val()).toUpperCase()); });
    

    that way you guarantee that future elements receive the keyup handler The root element is needed to limit the DOM monitoring scope for the on function. Ideally this would be a DIV element

    0 讨论(0)
  • 2021-01-20 18:06
    1. To make the code work on IE: Remove "console.log" instruction
    2. To change the date format, you can define a binding like this one:

      data-bind='datepicker: beschikkingsdatum, datepickerOptions: {dateFormat: "dd/mm/yy"}, uniqueName: true'

    0 讨论(0)
提交回复
热议问题