浏览代码

HUE-5549 [core] Make max length for a newly created Selectize value customizable

Enrico Berti 9 年之前
父节点
当前提交
d2ed8f5
共有 1 个文件被更改,包括 8 次插入1 次删除
  1. 8 1
      desktop/core/src/desktop/static/desktop/ext/js/knockout-selectize.js

+ 8 - 1
desktop/core/src/desktop/static/desktop/ext/js/knockout-selectize.js

@@ -32,7 +32,14 @@ ko.bindingHandlers.selectize = {
     if (allBindingsAccessor.has('selectizeOptions')) {
       var passed_options = allBindingsAccessor.get('selectizeOptions')
       for (var attr_name in passed_options) {
-        options[attr_name] = passed_options[attr_name];
+        if (attr_name === 'maxLength') {
+          options.createFilter = function (input) {
+            return input.length <= passed_options[attr_name]
+          }
+        }
+        else {
+          options[attr_name] = passed_options[attr_name];
+        }
       }
     }