Skip to content

Commit

Permalink
knockout#258 - for event and click docs, make examples consistent and…
Browse files Browse the repository at this point in the history
… provide link to 'bind' documentation.
  • Loading branch information
mbest committed Mar 20, 2012
1 parent 4cef39f commit 921e63c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions documentation/click-binding.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ In some scenarios, you may need to access the DOM event object associated with y

If you need to pass more parameters, one way to do it is by wrapping your handler in a function literal that takes in a parameter, as in this example:

<button data-bind="click: function(data, event) { myFunction(data, event, 'param1', 'param2') }">
<button data-bind="click: function(data, event) { myFunction('param1', 'param2', data, event) }">
Click me
</button>

Now, KO will pass the data and event objects to your function literal, which are then available to be passed to your handler.

Alternatively, if you prefer to avoid the function literal in your view, you can use the `bind` function, which attaches specific parameter values to a function reference:
Alternatively, if you prefer to avoid the function literal in your view, you can use the [bind](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/bind) function, which attaches specific parameter values to a function reference:

<button data-bind="click: myFunction.bind($data, 'param1', 'param2')">
Click me
Expand Down
4 changes: 2 additions & 2 deletions documentation/event-binding.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ In some scenarios, you may need to access the DOM event object associated with y

If you need to pass more parameters, one way to do it is by wrapping your handler in a function literal that takes in a parameter, as in this example:

<div data-bind="event: { mouseover: function(data, event) { myFunction(data, event, 'param1', 'param2') } }">
<div data-bind="event: { mouseover: function(data, event) { myFunction('param1', 'param2', data, event) } }">
Mouse over me
</div>

Now, KO will pass the event to your function literal, which is then available to be passed to your handler.

Alternatively, if you prefer to avoid the function literal in your view, you can use the `bind` function, which attaches specific parameter values to a function reference:
Alternatively, if you prefer to avoid the function literal in your view, you can use the [bind](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/bind) function, which attaches specific parameter values to a function reference:

<button data-bind="event: { mouseover: myFunction.bind($data, 'param1', 'param2') }">
Click me
Expand Down

0 comments on commit 921e63c

Please sign in to comment.