Created
December 2, 2013 22:00
-
-
Save miere/7759857 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Grant that will memorize all parameters and return a method | |
* that could run the original function with memorized parameters. | |
* | |
* @returns {Function} | |
*/ | |
Function.prototype.withParameters = function (){ | |
var args = arguments | |
var self = this | |
return function (){ | |
return self.apply( self, args ) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- In a simple grid with editable user list... --> | |
<tr data-bind="foreach: users"> | |
<!-- ... you can bind your edit function passing 'id' parameter like this --> | |
<td> <button data-bind="click: $parent.edit.withParameters( $data.id )">Edit me</button> </td> | |
<td data-bind="text: name"></td> | |
</tr> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment