From 5fddd49613bea66e5104505fe4aa288d79673a1d Mon Sep 17 00:00:00 2001 From: Anyon Date: Wed, 21 Oct 2020 18:45:49 +0800 Subject: [PATCH] Update admin.js --- public/static/admin.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/public/static/admin.js b/public/static/admin.js index d15ac7dfa..94df0a845 100644 --- a/public/static/admin.js +++ b/public/static/admin.js @@ -580,13 +580,9 @@ $(function () { $this.parent().append($box.append($text)), $text.off('keydown blur'), (tags.length > 0 && showTags(tags)); $text.on('keydown blur', function (event, value) { if (event.keyCode === 13 || event.type === 'blur') { - event.preventDefault(), (value = $text.val()); - if (tags.indexOf($(this).val()) > -1) { - layer.msg('该标签已存在') - } else if ((value + '').replace(/\s+/g, '').length > 0) { - tags.push(value), $this.val(tags.join(',')); - showTags([value]), this.focus(), $text.val(''); - } + event.preventDefault(), (value = $text.val().replace(/^\s*|\s*$/g, '')); + if (tags.indexOf($(this).val()) > -1) return layer.msg('该标签已经存在!'); + if (value.length > 0) tags.push(value), $this.val(tags.join(',')), showTags([value]), this.focus(), $text.val(''); } });