Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

viewModel update doesn't toggle the checkbox #140

Open
Whip opened this issue Dec 19, 2021 · 0 comments
Open

viewModel update doesn't toggle the checkbox #140

Whip opened this issue Dec 19, 2021 · 0 comments

Comments

@Whip
Copy link

Whip commented Dec 19, 2021

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant