[javascript] extract ajax postprocessing in a separate function
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>
Fri, 30 Jan 2009 16:52:00 +0100
changeset 540 e5c97f6f119d
parent 539 6ed63265764e
child 541 0d75cfe50f83
[javascript] extract ajax postprocessing in a separate function
web/data/cubicweb.ajax.js
--- a/web/data/cubicweb.ajax.js	Fri Jan 30 15:55:03 2009 +0100
+++ b/web/data/cubicweb.ajax.js	Fri Jan 30 16:52:00 2009 +0100
@@ -9,6 +9,23 @@
 
 var JSON_BASE_URL = baseuri() + 'json?';
 
+function postAjaxLoad(node) {
+    // find sortable tables if there are some
+    if (typeof(Sortable) != 'undefined') {
+	Sortable.sortTables(node);
+    }
+    // find textareas and wrap them if there are some
+    if (typeof(FCKeditor) != 'undefined') {
+	buildWysiwygEditors(node);
+    }
+    if (typeof initFacetBoxEvents != 'undefined') {
+	initFacetBoxEvents(node);
+    }
+    if (typeof buildWidgets != 'undefined') {
+	buildWidgets(node);
+    }
+}
+
 // cubicweb loadxhtml plugin to make jquery handle xhtml response
 jQuery.fn.loadxhtml = function(url, data, reqtype, mode) {
     var ajax = null;
@@ -40,28 +57,12 @@
 	} else if (mode == 'append') {
 	    jQuery(node).append(domnode);
 	}
-	// find sortable tables if there are some
-	if (typeof(Sortable) != 'undefined') {
-	    Sortable.sortTables(node);
-	}
-	// find textareas and wrap them if there are some
-	if (typeof(FCKeditor) != 'undefined') {
-	    buildWysiwygEditors(node);
-	}
-
-	if (typeof initFacetBoxEvents != 'undefined') {
-	    initFacetBoxEvents(node);
-	}
-
-	if (typeof buildWidgets != 'undefined') {
-	    buildWidgets(node);
-	}
-
+	postAjaxLoad(node);
 	while (jQuery.isFunction(callback)) {
 	    callback = callback.apply(this, [domnode]);
 	}
     });
-}
+};