-
Type:
Incident report
-
Resolution: False Positive
-
Priority:
Trivial
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
Steps to reproduce:
- Adding the following code for creating in CInput("checkbox") element in widget.view.php
<?php $powerLabel = new CLabel("Power On/Off", "powerLabel"); $powerLabel->addStyle("margin-left: 10px;"); $powerLabel->addStyle("margin-right: 3px;"); $powerCheckbox = new CInput("checkbox", "powerCheckbox", "on"); $powerCheckbox->setId("powerCheckbox"); $powerDiv = new CDiv([$powerLabel, $powerCheckbox]); $widgetView = new CWidgetView($data); $widgetView->addItem($powerDiv); $widgetView->show();
- Adding the following handling check status of CInput("checkbox") in class.widget.js
class WidgetAirConditioner extends CWidget { static powerCheckboxChanged() { const powerCheckbox = document.getElementById('powerCheckbox'); if (powerCheckbox) { if (powerCheckbox.checked) { console.log('Checkbox is checked.'); } else { console.log('Checkbox is unchecked.'); } } onInitialize() { } onResize() { } processUpdateResponse(response) { super.processUpdateResponse(response); } promiseReady() { return super.promiseReady(); } setContents(response) { super.setContents(response); const powerCheckbox = document.getElementById("powerCheckbox"); if (powerCheckbox) { powerCheckbox.addEventListener('change', WidgetHitachiAirConditioner.powerCheckboxChanged); } } onClearContents() { } }
Result:
Check status of powerCheckbox is checked after user presses powerCheckbox. But after few seconds, Check status of powerCheckbox is not checked.
Expected:
Check status of powerCheckbox is checked after user presses powerCheckbox. And after few seconds, Check status of powerCheckbox is still checked.
- depends on
-
ZBX-25695 Can't set check status of CInput('radio') in class.widget.js
-
- Closed
-