Made available call to external jQuery callbacks on add_fields click

This commit is contained in:
Tangerine Cat 2011-04-13 16:08:25 +06:00 committed by nathanvda
parent 630a88a704
commit cebcb21242
1 changed files with 9 additions and 2 deletions

View File

@ -12,6 +12,7 @@ $(document).ready(function() {
var content = $(this).attr('data-template');
var insertionPosition = $(this).attr('data-association-insertion-position');
var insertionNode = $(this).attr('data-association-insertion-node');
var insertionCallback = $(this).data('insertion-callback');
var regexp_braced = new RegExp('\\[new_' + assoc + '\\]', 'g');
var regexp_underscord = new RegExp('_new_' + assoc + '_', 'g');
var new_id = new Date().getTime();
@ -31,11 +32,17 @@ $(document).ready(function() {
else {
insertionNode = $(this).parent();
}
var contentNode = $(new_content);
if (insertionPosition == 'after'){
insertionNode.after(new_content);
insertionNode.after(contentNode);
} else {
insertionNode.before(new_content);
insertionNode.before(contentNode);
}
if(insertionCallback){
insertionCallback.call(contentNode);
}
return false;