luci-app-mosdns: fix TypeError by checking DOM element existence before setting innerHTML
* Added a check to confirm that the DOM element with ID 'service_status' exists before attempting to set its innerHTML. * Added a setTimeout to ensure the page is fully rendered before starting the polling process. Signed-off-by: sbwml <admin@cooluc.com>
This commit is contained in:
parent
92bf8db5a6
commit
6458fb296b
@ -1,7 +1,7 @@
|
|||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=luci-app-mosdns
|
PKG_NAME:=luci-app-mosdns
|
||||||
PKG_VERSION:=1.6.1
|
PKG_VERSION:=1.6.2
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=1
|
||||||
|
|
||||||
LUCI_TITLE:=LuCI Support for mosdns
|
LUCI_TITLE:=LuCI Support for mosdns
|
||||||
|
@ -68,12 +68,18 @@ return view.extend({
|
|||||||
s = m.section(form.TypedSection);
|
s = m.section(form.TypedSection);
|
||||||
s.anonymous = true;
|
s.anonymous = true;
|
||||||
s.render = function () {
|
s.render = function () {
|
||||||
poll.add(function () {
|
setTimeout(function () {
|
||||||
return L.resolveDefault(getServiceStatus()).then(function (res) {
|
poll.add(function () {
|
||||||
var view = document.getElementById('service_status');
|
return L.resolveDefault(getServiceStatus()).then(function (res) {
|
||||||
view.innerHTML = renderStatus(res);
|
var view = document.getElementById('service_status');
|
||||||
|
if (view) {
|
||||||
|
view.innerHTML = renderStatus(res);
|
||||||
|
} else {
|
||||||
|
console.error('Element #service_status not found.');
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
}, 100);
|
||||||
|
|
||||||
return E('div', { class: 'cbi-section', id: 'status_bar' }, [
|
return E('div', { class: 'cbi-section', id: 'status_bar' }, [
|
||||||
E('p', { id: 'service_status' }, _('Collecting data...'))
|
E('p', { id: 'service_status' }, _('Collecting data...'))
|
||||||
|
Loading…
Reference in New Issue
Block a user