Skip to content

Instantly share code, notes, and snippets.

@DrSammyD
Created December 8, 2014 23:19
Show Gist options
  • Save DrSammyD/2dbc9cce7ca8a978a7dc to your computer and use it in GitHub Desktop.
Save DrSammyD/2dbc9cce7ca8a978a7dc to your computer and use it in GitHub Desktop.
function which repeats an id a set amount of times and then increments
var repeat= function(reps){
var repeatOrig=ko.repeat;
repeatOrig.uid=!repeatOrig.uid?1:repeatOrig.uid+1;
var times = reps-1;
var repetion= function(){
if(--times<=0)
ko.repeat=repeatOrig;
return repeatOrig.uid;
};
ko.repeat=repetion;
return repeatOrig.uid;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment