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 need a stylesheet picker so I thought I'd build it my self :P
This is my first property editor and everything works as it should except for the initial state.
What I have now:
Controller:
angular.module("umbraco").controller("Webwonders.StylesheetPicker", function ($scope, stylesheetResource) { if (!$scope.stylesheets) { $scope.stylesheets = []; } stylesheetResource.getAll().then(function (stylesheets) { var emptyRadio = { name: "Geen stylesheet", path: ""}; $scope.stylesheets = stylesheets; $scope.stylesheets.splice(0, 0, emptyRadio); }); $scope.isSelected = function (stylesheet) { stylesheet.isSelected = $scope.model.value.name == stylesheet.name; return stylesheet.isSelected; }; $scope.selectStylesheet = function (stylesheet) { $scope.model.value = stylesheet; }; });
View:
<div ng-controller="Webwonders.StylesheetPicker" > <div ng-repeat="css in stylesheets"> <label> <input type="radio" name="stylesheets" ng-checked="isSelected(css)" ng-model="model.value" ng-change="selectStylesheet(css)" /> {{css.name}} </label> </div> <p>{{model.value}}</p> </div>
So model.value always has the correct value but all the radios are empty onload.
model.value
Any clues?
Ive put a console.log showing the stylesheets after $scope.stylesheets.splice(0, 0, emptyRadio); in the stylesheetResource.getAll() method.
$scope.stylesheets.splice(0, 0, emptyRadio);
stylesheetResource.getAll()
It looks like its only a visual problem because the correct isSelected is set to true.
isSelected
After I click on a radio the problem is solved and the radios show the correct state.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
Custom property editor initial state of radio list
I need a stylesheet picker so I thought I'd build it my self :P
This is my first property editor and everything works as it should except for the initial state.
What I have now:
Controller:
View:
So
model.value
always has the correct value but all the radios are empty onload.Any clues?
Ive put a console.log showing the stylesheets after
$scope.stylesheets.splice(0, 0, emptyRadio);
in thestylesheetResource.getAll()
method.It looks like its only a visual problem because the correct
isSelected
is set to true.After I click on a radio the problem is solved and the radios show the correct state.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion