[forms] add setFormsTarget() to the list of postAjaxLoad callbacks to have iframe on ajax-rendered forms stable
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>
Mon, 16 Nov 2009 17:20:03 +0100
branchstable
changeset 3863 fe22502d4ab1
parent 3862 4908c7156eab
child 3864 2fee9151c6b2
child 3869 ec6463886ac4
[forms] add setFormsTarget() to the list of postAjaxLoad callbacks to have iframe on ajax-rendered forms
web/data/cubicweb.ajax.js
web/data/cubicweb.edition.js
--- a/web/data/cubicweb.ajax.js	Mon Nov 16 17:18:48 2009 +0100
+++ b/web/data/cubicweb.ajax.js	Mon Nov 16 17:20:03 2009 +0100
@@ -62,6 +62,9 @@
     if (typeof roundedCorners != 'undefined') {
 	roundedCorners(node);
     }
+    if (typeof setFormsTarget != 'undefined') {
+       setFormsTarget(node);
+    }
     loadDynamicFragments(node);
     // XXX simulates document.ready, but the former
     // only runs once, this one potentially many times
--- a/web/data/cubicweb.edition.js	Mon Nov 16 17:18:48 2009 +0100
+++ b/web/data/cubicweb.edition.js	Mon Nov 16 17:20:03 2009 +0100
@@ -416,8 +416,9 @@
  * NOTE3: there is a XHTML module allowing iframe elements but there
  *        is still the problem of the form's `target` attribute
  */
-function setFormsTarget() {
-    jQuery('form.entityForm').each(function () {
+function setFormsTarget(node) {
+    var $node = jQuery(node || document.body);
+    $node.find('form.entityForm').each(function () {
 	var form = jQuery(this);
 	var target = form.attr('cubicweb:target');
 	if (target) {
@@ -431,7 +432,7 @@
     });
 }
 
-jQuery(document).ready(setFormsTarget);
+jQuery(document).ready(function() {setFormsTarget();});
 
 
 /*