Can't set button clicking handler in onInitialize() function of CWidget class

XMLWordPrintable

    • Type: Incident report
    • Resolution: False Positive
    • Priority: Trivial
    • None
    • Affects Version/s: None
    • Component/s: None
    • None

      Steps to reproduce:

      1. class WidgetTemperature extends CWidget {
            onInitialize() {
                this._button_callback_valid = false;
                var temperatureButton = document.getElementById('temperatureButton');
                if (temperatureButton) {
                    if (!this._button_callback_valid) {
                        this._button_callback_valid = true;
                        temperatureButton.addEventListener('click', function()
        Unknown macro: {                    var temperatureTextbox = document.getElementById('temperatureTextbox');                    alert(temperatureTextbox.value);                    // sending temperature to WebSocket server                    const socket = new WebSocket('ws}

        );
                    }
                }
        */        
            }
            
            onClearContents()

        {     }

        }

      Result:
      Button hanlder is not called if adding code for button handling in onInitialize(). But button hanlder is called if adding code for button handling in setContents().
      Expected:
      Button hanlder is called if adding code for button handling in onInitialize().

            Assignee:
            Zabbix Support Team
            Reporter:
            snow uyl
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: