Browse Source

优化附件选择按钮事件

Karson 3 years ago
parent
commit
a5163732af
1 changed files with 32 additions and 1 deletions
  1. 32 1
      public/assets/js/require-form.js

+ 32 - 1
public/assets/js/require-form.js

@@ -242,7 +242,7 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
             faselect: function (form) {
                 //绑定fachoose选择附件事件
                 if ($(".faselect,.fachoose", form).size() > 0) {
-                    $(".faselect,.fachoose", form).on('click', function () {
+                    $(".faselect,.fachoose", form).off('click').on('click', function () {
                         var that = this;
                         var multiple = $(this).data("multiple") ? $(this).data("multiple") : false;
                         var mimetype = $(this).data("mimetype") ? $(this).data("mimetype") : '';
@@ -413,6 +413,35 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
                     return false;
                 });
             },
+            tagsinput: function (form) {
+                //标签输入
+                $("input[data-toggle='tagsinput']").each(function () {
+                    var setting = {
+                        width: 'auto',
+                        defaultText: '输入后空格确认',
+                        minInputWidth: 110,
+                        height: '36px',
+                        placeholderColor: '#999',
+                        onChange: function (row) {
+                            $("input", $(this).next()).parent().focus();
+                            $("input", $(this).next()).trigger("blur.autocomplete").focus();
+                        },
+                    };
+                    var autocomplete = $(this).data("tagsinput-autocomplete");
+                    if (autocomplete) {
+                        if (typeof autocomplete == 'string') {
+                            autocomplete = {url: autocomplete};
+                        }
+                        setting['autocomplete'] = $.extend({
+                            url: '',
+                            minChars: 1,
+                            menuClass: 'autocomplete-tags'
+                        }, autocomplete);
+                    }
+                    setting = $.extend(true, setting, $(this).data("tagsinput") || {});
+                    $(this).tagsInput(setting);
+                });
+            },
             bindevent: function (form) {
 
             },
@@ -531,6 +560,8 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
                 events.slider(form);
 
                 events.switcher(form);
+
+                events.tagsinput(form);
             },
             custom: {}
         },