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