Commit a2240e9b authored by Sven Franck's avatar Sven Franck

app: fixed update of gadgets, allow elements to persist (will not be removed)

parent 2849dc8b
......@@ -1055,7 +1055,10 @@
"data-enhanced": "true",
"data-type": direction
},
"logic": {"id": spec.id || null}
"logic": {
"id": spec.id || null,
"data-persist": spec.persist || null
}
});
// controls
......@@ -1341,8 +1344,8 @@
"direct": {
"className": class_list
},
"attributes": {},
"logic": {
"data-persist": spec.persist || null,
"data-wrap": slot ? null : true,
"data-slot": slot ? true : null,
"data-slot-id": slot || null,
......@@ -6628,21 +6631,36 @@
// only for dynamic content
if (!pass.skip && !quirk_dict.no_content) {
// UPDATES
// UPDATES - same %&/( as above
if (quirk_dict.update) {
selector = pass.state.gadget;
update_target = selector.querySelector("[data-update]");
// dump
update_target = widget.querySelector("[data-update]") || widget.getElementsByTagName("form")[0];
// TODO: generic method!
// TODO: or inherit reference to controlgroup without being child of form?
// rescue persistent elements from dump
detach = document.createDocumentFragment();
child_list = update_target.children;
for (m = 0, len = child_list.length; m < len; m += 1) {
last_child = child_list[m];
if (last_child.getAttribute("data-persist")) {
detach.appendChild(last_child.cloneNode(true));
}
}
// clear
while (update_target.hasChildNodes()) {
update_target.removeChild(update_target.lastChild);
}
//and add new dynamic content
//add new dynamic content and detached elements
update_target.appendChild(wrapper.fragment);
update_target.appendChild(detach);
// CREATE
} else {
selector = wrapper.fragment.firstElementChild || wrapper.fragment;
// wrapped dyno
// TODO: find way to dig down into tree
if (util.testForString("dyno", selector.className) === false) {
......@@ -6657,6 +6675,8 @@
}
// if a callback is provided, set it on state
// TODO: once containers work, submit_to should change the container
// vs the whole page?
if (pass.config_dict.property_dict.submit_to) {
pass.state.callback = pass.config_dict.property_dict.submit_to;
}
......
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