I am trying to do something straight forward with Onsen UI -- automatically uncheck some checked switches. So, I have a number of switches and I want to mimic the radio-button behaviour (basically toggling one sets all others to non-checked).
I am using angular and I get this error when i try to do it from code.
Uncaught TypeError: document.getElementsByTagName(...)[0].setChecked is not a function(…)
Basically I tried
$scope.$on('toggle', function(event, data) {
$scope.selected[data] = event.targetScope.model;
for (i = 0; i < $scope.selected.length; i++) {
if (i != data) {
$scope.selected[i] = !$scope.selected[data];
}
}
});
All my switches are added dynamically using:
> var h = '<ons-list-item><div class="center">' + placeResult.name
> + '</div><div class="right"><ons-switch id="switch' + i
> + '" "ng-model="mySwitch' + i
> + '" ng-click="$emit(\'toggle\',' + i
> + ')"></ons-switch> </div></ons-list-item>';
I don't know if dynamically adding them basically has any issues?
I tried the same code with the preset switches and it works.
Thanks