[javascript] allow customization of inlineCreationForm insertion point stable
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>
Fri, 14 Aug 2009 19:01:45 +0200
branchstable
changeset 2859 822258915ff0
parent 2858 322272c5d67f
child 2860 b2add17d5bc4
[javascript] allow customization of inlineCreationForm insertion point
web/data/cubicweb.edition.js
--- a/web/data/cubicweb.edition.js	Fri Aug 14 18:55:31 2009 +0200
+++ b/web/data/cubicweb.edition.js	Fri Aug 14 19:01:45 2009 +0200
@@ -243,22 +243,22 @@
  * @param ttype : the target (inlined) entity type
  * @param rtype : the relation type between both entities
  */
-function addInlineCreationForm(peid, ttype, rtype, role) {
+function addInlineCreationForm(peid, ttype, rtype, role, insertBefore) {
+    insertBefore = insertBefore || getNode('add' + rtype + ':' + peid + 'link').parentNode;
     var d = asyncRemoteExec('inline_creation_form', peid, ttype, rtype, role);
     d.addCallback(function (response) {
-	var linknode = getNode('add' + rtype + ':' + peid + 'link');
         var dom = getDomFromResponse(response);
-	preprocessAjaxLoad(null, dom);
-	var form = jQuery(dom);
-	form.css('display', 'none');
-	form.insertBefore(linknode.parentNode).slideDown('fast');
-	updateInlinedEntitiesCounters(rtype);
-	reorderTabindex();
-	form.trigger('inlinedform-added');
+        preprocessAjaxLoad(null, dom);
+        var form = jQuery(dom);
+        form.css('display', 'none');
+        form.insertBefore(insertBefore).slideDown('fast');
+        updateInlinedEntitiesCounters(rtype);
+        reorderTabindex();
+        form.trigger('inlinedform-added');
         postAjaxLoad(dom);
     });
     d.addErrback(function (xxx) {
-	log('xxx =', xxx);
+        log('xxx =', xxx);
     });
 }