Skip to content
Browse files

jQuery: Making generated ids easily overridable

The ids were previously prefixed with 'new_', which we found useful,
but that was removed when #199 was fixed.
  • Loading branch information...
1 parent f6cc0fe commit e4a157030a76800b45d78b3247dbc7df855a08ae @ghostganz ghostganz committed Nov 6, 2012
Showing with 4 additions and 1 deletion.
  1. +4 −1 vendor/assets/javascripts/jquery_nested_form.js
View
5 vendor/assets/javascripts/jquery_nested_form.js
@@ -39,7 +39,7 @@ jQuery(function($) {
// Make a unique ID for the new child
var regexp = new RegExp('new_' + assoc, 'g');
- var new_id = new Date().getTime();
+ var new_id = this.newId();
content = content.replace(regexp, new_id);
var field = this.insertFields(content, assoc, link);
@@ -49,6 +49,9 @@ jQuery(function($) {
.trigger({ type: 'nested:fieldAdded:' + assoc, field: field });
return false;
},
+ newId: function() {
+ return new Date().getTime();
+ },
insertFields: function(content, assoc, link) {
return $(content).insertBefore(link);
},

0 comments on commit e4a1570

Please sign in to comment.
Something went wrong with that request. Please try again.