From c9c13b9c26b9639611490cdf1d87325fc36807bc Mon Sep 17 00:00:00 2001 From: zhangwei Date: Tue, 10 Jul 2018 11:26:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=B3=E9=94=AE=E5=AD=97=E4=B8=8E=E8=A1=A8?= =?UTF-8?q?=E8=BE=BE=E5=BC=8F=E9=99=90=E5=88=B6=E6=9C=80=E5=A4=9A4?= =?UTF-8?q?=E4=B8=AA=E5=85=B3=E9=94=AE=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangwei --- src/main/webapp/static/global/scripts/common.js | 1 + .../webapp/static/global/scripts/jquery.tagsinput.js | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/webapp/static/global/scripts/common.js b/src/main/webapp/static/global/scripts/common.js index 6f4e6c694..0ec31e514 100644 --- a/src/main/webapp/static/global/scripts/common.js +++ b/src/main/webapp/static/global/scripts/common.js @@ -238,6 +238,7 @@ $(function(){ width:$(tagsInputSettings).find(".form-control").width(), defaultText:'please input keywords', 'delimiter':'***and***',//特殊字符串分隔与表达式的多关键词 + maxCount:4, onAddTag:function(tag,size){ //var keywordValue = ""; var objNamePrefix = $(this).attr("name").split("cfgKeywords")[0]; diff --git a/src/main/webapp/static/global/scripts/jquery.tagsinput.js b/src/main/webapp/static/global/scripts/jquery.tagsinput.js index 0ffc4bb02..6de889359 100644 --- a/src/main/webapp/static/global/scripts/jquery.tagsinput.js +++ b/src/main/webapp/static/global/scripts/jquery.tagsinput.js @@ -15,7 +15,7 @@ */ (function($) { - + var kaiOptions = new Array(); var delimiter = new Array(); var tags_callbacks = new Array(); $.fn.doAutosize = function(o){ @@ -82,6 +82,11 @@ tagslist = new Array(); } + var maxCount=kaiOptions[id]['maxCount']; + if(maxCount>0 && tagslist.length>maxCount-1){ + $('#'+id+'_tag').addClass('not_valid'); + return ; + } value = jQuery.trim(value); if (options.unique) { @@ -190,6 +195,7 @@ placeholderColor:'#666666', autosize: true, comfortZone: 20, + maxCount:0, inputPadding: 6*2 },options); @@ -210,6 +216,8 @@ fake_input: '#'+id+'_tag' },settings); + kaiOptions[id] = new Array(); + kaiOptions[id]['maxCount']=settings.maxCount; delimiter[id] = data.delimiter; if (settings.onAddTag || settings.onRemoveTag || settings.onChange) {