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

View File

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