knockout.js - knockoutjs function argument ordering -


i want confirmation regarding argument ordering in knockout js method binding

situationa: if send in $data , event, first argument data, second argument dom event

<a data-bind="click: $root.myfunction.bind($data)" href="#">add sheet</a> self.myfunction = function (data, event) {} 

situationb: if send in parameter, $data becomes last parameter in myfunction, while myparam holds value "funnyworld"

<a data-bind="click: $root.myfunction.bind($data,'funnyworld')" href="#">add sheet</a> self.myfunction = function (myparam, data) {} 

do understand arugment order correctly?

situation a:

$root.myfunction.bind($data) 

would cause this in myfunction current view-model ($data). usual arguments passed knockout well, arguments be:

self.myfunction = function (arg1, arg2) {       // === $data       // arg1 === $data       // arg2 === event } 

situation b:

$root.myfunction.bind($data, 'funnyworld') 

would cause this in myfunction current view-model ($data) make first argument 'funnyworld':

self.myfunction = function (arg1, arg2, arg3) {       // === $data       // arg1 === 'funnyworld'       // arg2 === $data       // arg3 === event } 

see mdn


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -