Skip to content

More examples for vue #143

Open
Open
@SlavMAK

Description

@SlavMAK

Hello.
It works a little unusual (relative to the standard vue logic).

I implemented the radio buttons as follows. Please leave it here or take it out in the readme.

in template:

<check-box 
                        :ref="`checbox_${item.ID}`" 
                        :checked="localValue[itemIdx].checked" 
                        :text='item.VALUE' 
                        @checkedChange='localValue[itemIdx].checked = $event.value; onItemTap(item, itemIdx);'
                        :boxType="multiple?'square':'circle'"
                    />

event handler onItemTap:

onItemTap(item, itemIdx){
            if (this.stopEvents) return;
            this.stopEvents=true;
            if (!this.multiple){
                for(const idx in this.localValue){
                    if(this.localValue[idx].checked&&idx!=itemIdx){
                        this.$set(this.localValue[idx], 'checked', false);
                        this.$refs[`checbox_${this.localValue[idx].ID}`].nativeView.checked=false
                    }
                }
            }
            this.stopEvents=false;
        }

I use stopEvents so that removing unnecessary elements does not trigger the checkedChange event.

If there is a more concise solution, I will be glad to help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions