Skip to content

Commit e4a1570

Browse files
committed
jQuery: Making generated ids easily overridable
The ids were previously prefixed with 'new_', which we found useful, but that was removed when ryanb#199 was fixed.
1 parent f6cc0fe commit e4a1570

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

vendor/assets/javascripts/jquery_nested_form.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jQuery(function($) {
3939

4040
// Make a unique ID for the new child
4141
var regexp = new RegExp('new_' + assoc, 'g');
42-
var new_id = new Date().getTime();
42+
var new_id = this.newId();
4343
content = content.replace(regexp, new_id);
4444

4545
var field = this.insertFields(content, assoc, link);
@@ -49,6 +49,9 @@ jQuery(function($) {
4949
.trigger({ type: 'nested:fieldAdded:' + assoc, field: field });
5050
return false;
5151
},
52+
newId: function() {
53+
return new Date().getTime();
54+
},
5255
insertFields: function(content, assoc, link) {
5356
return $(content).insertBefore(link);
5457
},

0 commit comments

Comments
 (0)