D
D
Dubrovin2018-02-07 11:09:36
JavaScript
Dubrovin, 2018-02-07 11:09:36

How to remove Failed to execute dispatchEvent error?

There is such an element (Number-Slider) on the page: prntscr.com/ib96so
Number-Slider, respectively, consists of Number and Slider, which in turn have setValue methods that cause Number's Change event to fire and Slider, respectively.
As planned, it works like this: We change the value in number, the number's setValue method is called, the number-slider's listener reacts to this event and calls the slider's setValue method and vice versa, we move the slider, the slider's change fires, the setValue is called number.
The problem is that the change events start calling each other and throw an error:
prntscr.com/ib98r9
The listeners in the Number Slider look like this:

k.on( this.number.el, 'change', () => {
      let value = this.number.getValue();
      this.slider.setValue( value );
    } );

    k.on( this.slider.el, 'change', () => {
      let value = this.slider.getValue();
      this.number.setValue( value );
    } );

In fact, everything works, but there is an error. How can this be fixed?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question