Commit dc524389 authored by Ivan Tyagov's avatar Ivan Tyagov

register all gadget in advance so checkAndTriggerReady

can have accurate information for list of all gadgets.
parent 8d5df8ca
...@@ -44,8 +44,18 @@ var RenderJs = (function () { ...@@ -44,8 +44,18 @@ var RenderJs = (function () {
load: function (root) { load: function (root) {
/* Load gadget layout by traversing DOM */ /* Load gadget layout by traversing DOM */
var gadget_list; var gadget_list, gadget, gadget_id, gadget_js;
gadget_list = root.find("[data-gadget]"); gadget_list = root.find("[data-gadget]");
// register all gadget in advance so checkAndTriggerReady
// can have accurate information for list of all gadgets
gadget_list.each(function () {
gadget = $(this);
gadget_id = gadget.attr("id");
gadget_js = new RenderJs.Gadget(gadget_id, gadget);
RenderJs.GadgetIndex.registerGadget(gadget_js);
});
// Load chilren // Load chilren
gadget_list.each(function () { gadget_list.each(function () {
RenderJs.loadGadgetFromUrl($(this)); RenderJs.loadGadgetFromUrl($(this));
...@@ -65,9 +75,12 @@ var RenderJs = (function () { ...@@ -65,9 +75,12 @@ var RenderJs = (function () {
app_cache, data, gadget_js; app_cache, data, gadget_js;
url = gadget.attr("data-gadget"); url = gadget.attr("data-gadget");
gadget_id = gadget.attr("id"); gadget_id = gadget.attr("id");
// register gadget in javascript namespace gadget_js = RenderJs.GadgetIndex.getGadgetById(gadget_id);
if (gadget_js===undefined) {
// register gadget in javascript namespace if not already registered
gadget_js = new RenderJs.Gadget(gadget_id, gadget); gadget_js = new RenderJs.Gadget(gadget_id, gadget);
RenderJs.GadgetIndex.registerGadget(gadget_js); RenderJs.GadgetIndex.registerGadget(gadget_js);
}
// update Gadget's instance with contents of "data-gadget-property" // update Gadget's instance with contents of "data-gadget-property"
gadget_property = gadget.attr("data-gadget-property"); gadget_property = gadget.attr("data-gadget-property");
......
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