Knockout 2.2.0 error with jQuery 1.9

前端 未结 2 1161
我寻月下人不归
我寻月下人不归 2021-01-11 09:51

I copied one of examples of knockoutjs:

    
    
    
      

        
相关标签:
2条回答
  • 2021-01-11 10:25

    Updating Knockout to 2.2.1 solves the problem for me:

    • 2.2.0: http://jsfiddle.net/UDSBC/2/
    • 2.2.1: http://jsfiddle.net/UDSBC/1/

    So just change:

    <script src="http://cdnjs.cloudflare.com/ajax/libs/knockout/2.2.0/knockout-min.js"></script>
    

    To:

    <script src="http://cdnjs.cloudflare.com/ajax/libs/knockout/2.2.1/knockout-min.js"></script>
    

    And it'll work.

    0 讨论(0)
  • 2021-01-11 10:27

    The Cause

    You are not using the most current version of Knockout. The previous version, 2.2.0, is incompatible with jQuery 1.9.x and on. See this Knockout dev thread:

    Knockout 2.2.0 uses jQuery.clean() which is deprecated and does not exist in 1.9.

    This means that Knockout 2.2.0 is calling an undefined jQuery method, thus triggering the JS error you specified.

    Solutions

    1. Consider updating to the latest version of Knockout which is compatible with jQuery 1.9
    2. If you can't, use the jQuery Migrate plugin which adds backward-compatibility to jQuery 1.9
    3. If all else fails, you'll need to revert back to jQuery 1.8
    0 讨论(0)
提交回复
热议问题