javascript - On click function parameters Knockout -
i trying pass 1 parameter function knockout click binding. if try sending without binding, works.
here fiddle of working code without binding:
https://jsfiddle.net/obviously/ev0lcx7q/4/
but if try binding this, not works:
<input class="sometextbox"> <button type="button" data-bind="click: $root.somefunction.bind($root,$(this).siblings('input').val())"> search! </button>
i error @ $(this), javascript runtime error: object doesn't support property or method 'siblings'
$element
gives access current element in knockout binding.
<input class="sometextbox"> <button type="button" data-bind="click: $root.somefunction.bind($root, $($element).siblings('input').val())"> search! </button>
note using jquery in knockout binding not common approach.
Comments
Post a Comment