Skip to content

@nstudio/nativescript-checkbox: Toggle is being called twice when binding the checked to an attribute. #132

Open
@leftundersun

Description

@leftundersun

If you make it this way:

<template>
  <Page>
    <StackLayout
      orientation="vertical">
      <check-box
        v-for="(option, index) in options"
        :key="index"
        :text="option"
        :checked="index == selected"
        boxType="circle"
        @tap="selectOption(index)"
        @checkedChange="changed(index)"/>
    </StackLayout>
  </Page>
</template>

<script lang="coffee">

export default
  
  data: () ->
    {
      options: [
        "First"
        "Second"
        "Third"
        "Fourth"
      ]
      selected: null
    }

  methods:

    selectOption: (index) ->
      if this.selected == index
        this.selected = null
      else
        this.selected = index

    changed: (index) ->
      console.log "changed #{index}"

</script>

and click on an already selected option, you became able to select another one.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions