web/data/cubicweb.lazy.js
changeset 485 0f830732be19
child 522 385ce5e0b30b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/data/cubicweb.lazy.js	Tue Jan 27 18:46:49 2009 +0100
@@ -0,0 +1,22 @@
+
+function load_now(eltsel, holesel) {
+  var lazydiv = jQuery(eltsel);
+  var hole = lazydiv.children(holesel);
+  if (hole.length == 0) /* the hole is already filled */
+    return;
+  var vid_eid = lazydiv.attr('cubicweb__loadurl');
+  /* XXX see what could be done with jquery.loadxhtml(...)   */
+  var later = async_rawremote_exec('lazily', vid_eid);
+  later.addCallback(function(req) {
+    var div = lazydiv[0];
+    div.appendChild(getDomFromResponse(req));
+    div.removeChild(hole[0]);
+  });
+  later.addErrback(function(err) {
+    log(err);
+  });
+}
+
+function trigger_load(divid) {
+  jQuery('#lazy-' + divid).trigger('load_' + divid);
+}
\ No newline at end of file