Skip to content

Instantly share code, notes, and snippets.

@fdeandao
Forked from miere/gist:7759857
Last active August 29, 2015 14:05
Show Gist options
  • Save fdeandao/50a6338a0f806fecec4f to your computer and use it in GitHub Desktop.
Save fdeandao/50a6338a0f806fecec4f to your computer and use it in GitHub Desktop.
Llamar funciones con parametros
/**
* 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 )
}
}
<!-- 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