Umbraco Json 到 css class="[]"

Umbraco Json to css class="[]"

我正在使用 Umbraco 并且正在使用数据类型的网格布局,并且想为每个 row/cell 添加自定义设置 (css 类) 并且它有点工作。用户界面:

"modifier": "{X}" 给出了不同的结果 3 "best"。

和json:

[
  {
    "label": "Message Box",
    "description": "Message Box",
    "key": "class",
    "view": "checkbox",
    "modifier": "{3}",
    "applyTo": "cell",
    "config": {
      "items": {
        "key1": {
          "value": "value1"
        },
        "key2": {
          "value": "value2"
        },
        "key3": {
          "value": "value3"
        },
        "key4": {
          "value": "value4"
        }
      }
    }
  }
]

但是我应用这些 类 的 cell/rows 最终看起来像这样

<div class="["key1", "key2", "key3", "key4"]">

并且 html 不能理解这些 类 当它们有 [] 和逗号之后我怎样才能使 类 正确地应用于元素?

Pastebin 修改后的 Foundation5

Umbracos 复选框代码

Pastebin

改变这个:

    $scope.$watch('selectedItems', function (newVal, oldVal) {
        $scope.model.value = [];
        for (var x = 0; x < $scope.selectedItems.length; x++) {
            if ($scope.selectedItems[x].checked) {
                $scope.model.value.push($scope.selectedItems[x].key);
            }
        }
    }, true);

进入这个:

    $scope.$watch('selectedItems', function (newVal, oldVal) {
        var classList = [];
        for (var x = 0; x < $scope.selectedItems.length; x++) {
            if ($scope.selectedItems[x].checked) {
                classList.push($scope.selectedItems[x].key);
            }
        }
        $scope.model.value = classList.join(' '); // imploding class list
    }, true);

与其将带有 class 列表的整个数组添加到您的前端,不如将您的数组内爆并用空格分隔各个 classes。