Skip to content

viewModel update doesn't toggle the checkbox #140

@Whip

Description

@Whip

I'm using this checkbox plugin inside ui-collections list. I want the user to tap the list item anywhere and that should toggle its checkbox but that doesn't happen. The viewModel updates but the checkbox doesn't. I can not get the checkbox view to call the toggle function on it (I don't know how) so I was hoping the checkbox will toggle when its checked state changes. Here's my code

<gv:CollectionView items="{{ list }}" colWidth="49%" id="collection" itemTap="onItemSelected">
  <gv:CollectionView.itemTemplate>
    <GridLayout rows="*,auto" class="bg-trans" margin="5">
    	<i:ImageCacheIt row="0" width="{{ width }}" height="{{ width }}" decodeWidth="{{ width }}" decodeHeight="{{ width }}" progressiveRenderingEnabled="true" src="{{ image }}" placeholderImageUri="~/images/loading.jpg" failureImageUri="~/images/loading.jpg" stretch="aspectFill" />
	<CheckBox:CheckBox row="0" checked="{{ checked }}" text="" verticalAlignment="top" horizontalAlignment="right" fillColor="#363636" id="{{ 'check'+id }}" isUserInteractionEnabled="false" ios:backgroundColor="transparent" ios:width="20" />
    	<StackLayout row="0" verticalAlignment="bottom" class="cat-caption">
    		<Label text="{{ name }}" verticalAlignment="center" />
    	</StackLayout>
    </GridLayout>
  </gv:CollectionView.itemTemplate>
</gv:CollectionView>
export function onItemSelected(args){
  const selectedItem = viewModel.list[args.index];

  if(selectedItem.checked)
    viewModel.list[args.index].checked = false;
  else
    viewModel.list[args.index].checked = true;
}

Is it possible to toggle the checkbox through updating the viewModel?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions