Knockout 2.0 parameters from bind in incorrect order ?



  • 2 Answer(s)

        This is the explanation for the error :

        The 1st parameter will be the value of this during call the  bind . So, In the  call, 1st argument will be $parent & the this will be $data .

        Do this If $root is $parent .

    $root.deleteSomeEntity.bind($root)
    
    

        This will be set to $root .If the KO will transfer the data as the 1st parameter .

        Do this If the $parent is not the  $root :

    $root.deleteSomeEntity.bind($root, $data, $parent)
    
    

    Or

        Some other way also there to check the proper this inside the  view model . Even though  It is based on the  structure .

    Answered on December 31, 2018.
    Add Comment

        See this  for removing  the error :

        If the javascript function is written  as the click event By default,The K.O will pass $data as the first argument and the event as the second. So do not use the bind .

    http://knockoutjs.com/documentation/click-binding.html 

        Do this and the bind is not needed .

    data-bind="click: function() {$root.deleteSomeEntity($data, $parent)}"
    
    Answered on December 31, 2018.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.