Commit cb263573 authored by Ivan Tyagov's avatar Ivan Tyagov

We need to explicitly call bind.

Catch events only once.
Remove dead code.
Simplify addGadget.
parent ccf13197
...@@ -14,13 +14,6 @@ var RENDERJS_ENABLE_IMPLICIT_GADGET_RENDERING = true; ...@@ -14,13 +14,6 @@ var RENDERJS_ENABLE_IMPLICIT_GADGET_RENDERING = true;
// available // available
var RENDERJS_ENABLE_IMPLICIT_INTERACTION_BIND = true; var RENDERJS_ENABLE_IMPLICIT_INTERACTION_BIND = true;
if (typeof require !== 'undefined') {
// XXX: think how to use requirejs to load jquery upfront (and if it's possible)
// example of how we can use requirejs to load external libraries
//require(["../../../../lib/jstorage/jstorage.js"], function (util) {
//});
}
// fallback for IE // fallback for IE
if (typeof console === "undefined" || typeof console.log === "undefined") { if (typeof console === "undefined" || typeof console.log === "undefined") {
console = {}; console = {};
...@@ -262,18 +255,9 @@ var RenderJs = (function () { ...@@ -262,18 +255,9 @@ var RenderJs = (function () {
tab_container.append(html_string); tab_container.append(html_string);
tab_gadget = tab_container.find(".gadget"); tab_gadget = tab_container.find(".gadget");
// render new gadget // render new gadget
RenderJs.setReady(false);
RenderJs.loadGadgetFromUrl(tab_gadget); RenderJs.loadGadgetFromUrl(tab_gadget);
// clear previous events // this will make RenderJs fire "ready" event when all gadgets are loaded.
RenderJs.GadgetIndex.getRootGadget().getDom().bind( RenderJs.setReady(false);
"ready",
function () {
if (!is_ready) {
RenderJs.updateGadgetData(tab_gadget);
is_ready = true;
}
}
);
return tab_gadget; return tab_gadget;
}, },
......
...@@ -81,10 +81,9 @@ function setupRenderJSTest(){ ...@@ -81,10 +81,9 @@ function setupRenderJSTest(){
stop(); stop();
// we need to wait for all gadgets loading ... // we need to wait for all gadgets loading ...
RenderJs.GadgetIndex.getRootGadget().getDom().bind("ready", function () { RenderJs.GadgetIndex.getRootGadget().getDom().one("ready", function () {
start(); start();
equal(true, RenderJs.GadgetIndex.isGadgetListLoaded()); equal(true, RenderJs.GadgetIndex.isGadgetListLoaded());
equal(true, RenderJs.isReady());
}); });
}); });
...@@ -96,6 +95,7 @@ function setupRenderJSTest(){ ...@@ -96,6 +95,7 @@ function setupRenderJSTest(){
// we need to wait for all gadgets loading ... // we need to wait for all gadgets loading ...
RenderJs.GadgetIndex.getRootGadget().getDom().bind("ready", function () { RenderJs.GadgetIndex.getRootGadget().getDom().bind("ready", function () {
RenderJs.InteractionGadget.bind($("#main-interactor"));
start(); start();
equal(0, counter); equal(0, counter);
// A.inc will call B.inc, both will increase counter by 1 // A.inc will call B.inc, both will increase counter by 1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment