diff --git a/lib/generators/cocoon/install/templates/cocoon.js b/lib/generators/cocoon/install/templates/cocoon.js index a5d2225..9a9ce0f 100644 --- a/lib/generators/cocoon/install/templates/cocoon.js +++ b/lib/generators/cocoon/install/templates/cocoon.js @@ -28,20 +28,23 @@ $(document).ready(function() { new_content = new_content.replace(regexp_underscord, newcontent_underscord); - if (insertionNode) + if (insertionNode){ insertionNode = $(insertionNode); - else + } else { insertionNode = $(this).parent(); + } var contentNode = $(new_content); - if (insertionPosition == 'after') + if (insertionPosition == 'after'){ insertionNode.after(contentNode); - else + } else { insertionNode.before(contentNode); - - if (insertionCallback) + } + + if (insertionCallback){ insertionCallback.call(contentNode); + } }); $('.remove_fields.dynamic').live('click', function(e) {