javascript - Wix 代码/为什么全选按钮不全选?
问题描述
我已经全选并删除了复选框的所有按钮。你可以看到下面的代码。但是错误是他应该选择所有选项(不是复选框中的所有选项。)为什么复选框不选择所有选项?有什么不足
详情 https://www.wix.com/velo/forum/community-discussion/why-doesn-t-the-select-all-button-select-all [![在此处输入图片描述][1]][1 ]
我的代码
export function CountrySelectAllt_click(event) {
// number of items in checkbox group
let totalItems = $w('#checkboxt1'+ ", " +'#checkboxt2'+ ", " +'#checkboxt3'+ ", "
+'#checkboxt4').options.length;
// initiate a newIndices array to hold all indices
let newIndices = [];
for (var i = 0; i < totalItems; i++) {
newIndices.push(i);
}
console.log(newIndices);
$w('#checkboxt1').selectedIndices = newIndices;
$w('#checkboxt2').selectedIndices = newIndices;
$w('#checkboxt3').selectedIndices = newIndices;
$w('#checkboxt4').selectedIndices = newIndices;
}
export function CountrySelectAlltreset_click(event) {
// number of items in checkbox group
let totalItems = $w('#checkboxt1'+ ", " +'#checkboxt2'+ ", " +'#checkboxt3'+ ", "
+'#checkboxt4').options.length;
// initiate a newIndices array to hold all indices
let newIndices = [];
for (var i = 0; i < totalItems; i++) {
newIndices.push(i);
}
console.log(newIndices);
$w('#checkboxt1').selectedIndices = [];
$w('#checkboxt2').selectedIndices = [];
$w('#checkboxt3').selectedIndices = [];
$w('#checkboxt4').selectedIndices = [];
}
[1]: https://i.stack.imgur.com/mQBT8.jpg
解决方案
在我看来,您正在混合 Checkboxes 和 CheckboxGroup 属性。Checkboxes 和 CheckboxGroups 是不同类型的元素。
似乎您已经添加了 Checkbox 元素,因为您列出了一堆 ID。但是随后您使用的selectedIndices
属性是 CheckboxGroup 属性。
推荐阅读
- javascript - 如何在 Zoho CRM Deluge 脚本中使用 for each 循环遍历 JSON 数组
- spring - Azure Blob 存储连接
- python - curl 将文件上传到 python 请求
- flutter - 如何在颤动的小部件中返回警报
- python - 当前在 VS Code 中运行 Python 的快捷方式
- spring-boot - Spring Boot 应用程序有时无法在高负载下“绑定属性”
- php - Hateoas Post,Put,Delete PHP, Codeigniter
- javascript - 尝试使用 mongoDB 查询填充选择菜单,导致“对象作为 React 子项无效(找到:[object Promise])。”
- android - 如何在 Android Kotlin 中从 Json 模式和 Ui 模式创建表单
- c# - Xamarin.Form 中的表视图