JSFiddle - React, Tailwind, and code Playground
by Gabriel Tran
HTML
<div style="margin-bottom:2em;">Open debugger before clicking on these links</div>
<a data-bind="click: path.to.method.bind($data, 'hey')">
Why p1 and p2 do not receive the good parameters with arguments like ['hey', $data] when click happens?
</a>
<a data-bind="click: function(){ path.to.method('hey', $data); }" style="margin-top:3em; display:block;">
And here it works as expected.
</a>
JavaScript
function VM(){
// In my model, I am namespacing things this way:
this.path = {
to: {
method: function(p1, p2) {
console.log(((p1 === 'hey')?'First parameter is as expected':'First parameter is NOT as expected'));
debugger;
}
}
}
}
ko.applyBindings(new VM());