Commit 6b37e9d1 authored by Sven Franck's avatar Sven Franck

app: add global delete children method

parent 1fd0fc77
......@@ -3167,9 +3167,7 @@
break;
default:
// NOTE: empty - setting .translate on a wrapper will empty it
while (element.hasChildNodes()) {
element.removeChild(element.firstChild);
}
util.deleteChildren(element);
element.appendChild(document.createTextNode(i18n.t(target[0])));
break;
}
......@@ -4723,7 +4721,6 @@
id = answer.id;
decode = /%[0-9a-f]{2}/i.test(id);
goto_page = decode ? id : window.encodeURIComponent(id);
$.mobile.changePage(obj.state.callback.replace("__id__", goto_page));
}
};
......@@ -5547,10 +5544,11 @@
}
}
});
} /*else {
} else {
// TODO: AAAARGH! so much jquery...
// TODO: AND IT DOES NOT WORK... §$%&/()=!
$(form_element).trigger("addField", $(form_element).find(".required"));
}*/
}
}
};
......@@ -5813,13 +5811,14 @@
* Get the active JQM page in JavaScript-only
* @method getPage
* @param {string} url url of the page to fetch
* @param {string} straight If not set, we start searching from behind
* @return {string} id of active page
*/
util.getPage = function (url) {
var i, kid, kids = document.body.children;
util.getPage = function (url, straight) {
var i, kid, len, kids = document.body.children;
// reverse, because in JQM last page is the active page!
for (i = kids.length - 1; i >= 0; i -= 1) {
for (len = kids.length, i = len - 1; i >= 0; i -= 1) {
kid = kids[i];
if (util.testForString("ui-page", kid.className)) {
......@@ -5831,6 +5830,17 @@
return undefined;
};
/**
* Remove all children of an element
* @method deleteChildren
* @param {object} el Element to remove children from
*/
util.deleteChildren = function (el) {
while (el.hasChildNodes()) {
el.removeChild(el.lastChild);
}
};
/**
* Reverse an array
* @method reverseArray
......@@ -6719,12 +6729,9 @@
detach.appendChild(last_child.cloneNode(true));
}
}
// clear
while (update_target.hasChildNodes()) {
update_target.removeChild(update_target.lastChild);
}
//add new dynamic content and detached elements
//empty target, add new dynamic content and detached elements
util.deleteChildren(update_target);
update_target.appendChild(wrapper.fragment);
update_target.appendChild(detach);
......
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