Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

Commit

Permalink
Merge pull request #215 from ghostganz/overridable_ids
Browse files Browse the repository at this point in the history
Making generated ids easily overridable (jQuery)
  • Loading branch information
lest committed Nov 6, 2012
2 parents f6cc0fe + e4a1570 commit c2e08e3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion vendor/assets/javascripts/jquery_nested_form.js
Expand Up @@ -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);
Expand All @@ -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);
},
Expand Down

0 comments on commit c2e08e3

Please sign in to comment.