Commit 48cd44fd authored by Sven Franck's avatar Sven Franck

App/modules: added forceRefresh option to force rebuild of gaget on reload

parent 6801c759
...@@ -265,7 +265,7 @@ define([ ...@@ -265,7 +265,7 @@ define([
// @method renderGadgets // @method renderGadgets
// @param {object} gadget to be rendered // @param {object} gadget to be rendered
// //
that.renderGadgets = function (gadget) { that.renderGadgets = function (gadget, forceRefresh) {
var gadget_id = gadget.dom.attr('id'), var gadget_id = gadget.dom.attr('id'),
gadget_parent = gadget.dom.parents("div[data-gadget]"), gadget_parent = gadget.dom.parents("div[data-gadget]"),
gadget_props, gadget_props,
...@@ -279,7 +279,7 @@ define([ ...@@ -279,7 +279,7 @@ define([
} }
// so now we do it here... // so now we do it here...
if (gadget.isEnhanced() === false) { if (gadget.isEnhanced() === false || forceRefresh) {
gadget.dom.parent().trigger("create"); gadget.dom.parent().trigger("create");
gadget.setEnhanced(true); gadget.setEnhanced(true);
} }
......
...@@ -119,11 +119,20 @@ define([ ...@@ -119,11 +119,20 @@ define([
spec.source = source; spec.source = source;
spec.callback_mockup = callback_mockup; spec.callback_mockup = callback_mockup;
// bind here, we attach to document if (!spec.page.getAttribute("events_pagination")) {
priv.setBindings(spec); spec.page.setAttribute("events_pagination", true);
$(document).on("pagebeforeshow.pagination", spec.pageId, function (e, data) {
// TODO: if we allow to reload, we also need to trigger refresh on
// so we need to reload this every time a page is shown. question
// is how to trigger a refresh on this element ONLY
// > the gadgets should tell whether they need enhancement!
// callback
priv.iterate(spec);
});
// callback // callback
priv.iterate(spec); priv.iterate(spec);
}
}; };
that.callback = function (self) { that.callback = function (self) {
...@@ -132,14 +141,14 @@ define([ ...@@ -132,14 +141,14 @@ define([
def.done(function(gadget) { def.done(function(gadget) {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
App.renderGadgets(gadget); App.renderGadgets(gadget, true);
}); });
window.fallbackLoader.deferreds.push(def); window.fallbackLoader.deferreds.push(def);
window.fallbackLoader.args.push(self); window.fallbackLoader.args.push(self);
} else { } else {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
App.renderGadgets(self); App.renderGadgets(self, true);
} }
}; };
......
...@@ -209,9 +209,7 @@ define([ ...@@ -209,9 +209,7 @@ define([
if (location.search) { if (location.search) {
spec.pointer = location.search.split("="); spec.pointer = location.search.split("=");
} }
if ($.mobile.firstPage.attr('id') !== spec.pageId.replace("#","")) { priv.generateItems(spec, true);
priv.generateItems(spec);
}
}) })
.on("click.gallery", spec.pageId + " .display_item", function (e) { .on("click.gallery", spec.pageId + " .display_item", function (e) {
var target = e.target, var target = e.target,
...@@ -235,14 +233,14 @@ define([ ...@@ -235,14 +233,14 @@ define([
def.done(function(gadget) { def.done(function(gadget) {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
App.renderGadgets(gadget); App.renderGadgets(gadget, true);
}); });
window.fallbackLoader.deferreds.push(def); window.fallbackLoader.deferreds.push(def);
window.fallbackLoader.args.push(self); window.fallbackLoader.args.push(self);
} else { } else {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
App.renderGadgets(self); App.renderGadgets(self, true);
} }
}; };
......
...@@ -111,9 +111,13 @@ define([ ...@@ -111,9 +111,13 @@ define([
if (!spec.page.getAttribute("events_items")) { if (!spec.page.getAttribute("events_items")) {
spec.page.setAttribute("events_items", true); spec.page.setAttribute("events_items", true);
$(document).on("pagebeforeshow.items", spec.pageId, function (e, data) { $(document).on("pagebeforeshow.items", spec.pageId, function (e, data) {
if ($.mobile.firstPage.attr('id') !== spec.pageId.replace("#","")) { // TODO: if we allow to reload, we also need to trigger refresh on
// so we need to reload this every time a page is shown. question
// is how to trigger a refresh on this element ONLY
// > the gadgets should tell whether they need enhancement!
//if ($.mobile.firstPage.attr('id') !== spec.pageId.replace("#","")) {
priv.generateItems(spec); priv.generateItems(spec);
} //}
}); });
// and run intial // and run intial
priv.generateItems(spec); priv.generateItems(spec);
...@@ -142,14 +146,14 @@ define([ ...@@ -142,14 +146,14 @@ define([
def.done(function(gadget) { def.done(function(gadget) {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
App.renderGadgets(gadget); App.renderGadgets(gadget, true);
}); });
window.fallbackLoader.deferreds.push(def); window.fallbackLoader.deferreds.push(def);
window.fallbackLoader.args.push(self); window.fallbackLoader.args.push(self);
} else { } else {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
App.renderGadgets(self); App.renderGadgets(self, true);
} }
}; };
......
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