Skip to content

Instantly share code, notes, and snippets.

@developish
Created April 13, 2011 03:18
Show Gist options
  • Save developish/916902 to your computer and use it in GitHub Desktop.
Save developish/916902 to your computer and use it in GitHub Desktop.
For adding nested form objects with Rails
// Works in conjunction with the generate_template helper to insert new
// objects into a form that has a collection of items.
$.fn.appendFromTemplate = function(template) {
return this.each(function () {
var newId = new Date().getTime();
$(this).append(template.replace(/NEW_RECORD/g, newId));
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment