Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I am trying to create a custom property editor with a checkbox.
The basic html checkbox is no problem, but how can i get the umbraco styles toggle button for TrueFalse?
I tried
<label class="checkbox"> <input type="checkbox" value="true" class="umb-property-editor umb-toggle" ng-model="model.value.applystylesheet"/>Apply Stylesheet </label>
Is there some css class missing?
<umb-toggle checked="model.value.applystylesheet" on-click="vm.toggle()"> </umb-toggle>
https://our.umbraco.com/apidocs/v8/ui/#/api/umbraco.directives.directive:umbToggle
Thanks for this hint!
My working source code:
JS:
var vm = this; vm.toggle = toggle; vm.disabled = false; vm.checked = $scope.model.value.applystylesheet; function toggle() { vm.checked = !vm.checked; $scope.model.value.applystylesheet = vm.checked; } $scope.vm = vm;
Html:
<umb-toggle checked="model.value.applystylesheet" disabled="vm.disabled" show-labels="true" label-on="Start" label-off="Stop" label-position="right" on-click="vm.toggle()"> </umb-toggle>
The documentation does not mentioned how to store the value back in the model. This prevents the view from updating the toggle button and storing the new value.
Hi Thobias.
I dunno why you can't store the new value. Aint that what you doing here?
function toggle() { vm.checked = !vm.checked; $scope.model.value.applystylesheet = vm.checked; }
At 8.6.2 the value was not stored without this line
$scope.model.value.applystylesheet = vm.checked;
I am not sure why, but it works for me.
Yes, thats correct. You need to assign the new value to your $scope.model.value.applystylesheet
function toggle() { $scope.model.value.applystylesheet = !$scope.model.value.applystylesheet; }
Yes. The code above is just an example. Needs to be refactored in some cases.
But for other people who have trouble, could this be helpful.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Property Editor - Checkbox Toggle
I am trying to create a custom property editor with a checkbox.
The basic html checkbox is no problem, but how can i get the umbraco styles toggle button for TrueFalse?
I tried
Is there some css class missing?
https://our.umbraco.com/apidocs/v8/ui/#/api/umbraco.directives.directive:umbToggle
Thanks for this hint!
My working source code:
JS:
Html:
The documentation does not mentioned how to store the value back in the model. This prevents the view from updating the toggle button and storing the new value.
Hi Thobias.
I dunno why you can't store the new value. Aint that what you doing here?
At 8.6.2 the value was not stored without this line
I am not sure why, but it works for me.
Yes, thats correct. You need to assign the new value to your $scope.model.value.applystylesheet
Yes. The code above is just an example. Needs to be refactored in some cases.
But for other people who have trouble, could this be helpful.
is working on a reply...