Toggle button group

Is it possible to make a toggle buttons group?
For example I have 3 toggles and I need the behavior like for radio - only one toggle button should be toggled at the same time.
How to do this, except handling onChange event and un-toggle all others?
Thanks!

Tagged:

Comments

  • For example I have two toggles and for now use this code:

            this.#toggle1.attachEvent('onChange', (value, prev, config) => {
                if (config == 'user') {
                    if (!Boolean(value) && Boolean(prev)) {
                        this.#toggle1.toggle();
                    } else if (Boolean(value)) {
                        this.#toggle2.setValue(false);
                        //...some code
                    }
                }
            });
    
            this.#toggle2.attachEvent('onChange', (value, prev, config) => {
                if (config == 'user') {
                    if (!Boolean(value) && Boolean(prev)) {
                        this.#toggle2.toggle();
                    } else if (Boolean(value)) {
                        this.#toggle1.setValue(false);
                        //...some code
                    }
                }
            });
    

    How it can be simplified?

  • I will answer for myself
    use segmented
    https://docs.webix.com/api__refs__ui.segmented.html

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!