Fixed tag input adding empty implications
This commit is contained in:
parent
99845af35b
commit
cefe701403
1 changed files with 8 additions and 2 deletions
|
@ -121,13 +121,19 @@ App.Controls.TagInput = function($underlyingInput) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function explodeText(text) {
|
||||||
|
return _.filter(text.trim().split(/\s+/), function(item) {
|
||||||
|
return item.length > 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function processText(text, callback) {
|
function processText(text, callback) {
|
||||||
var tagNamesToAdd = text.split(/\s+/);
|
var tagNamesToAdd = explodeText(text);
|
||||||
_.map(tagNamesToAdd, function(tagName) { callback(tagName); });
|
_.map(tagNamesToAdd, function(tagName) { callback(tagName); });
|
||||||
}
|
}
|
||||||
|
|
||||||
function processTextWithoutLast(text, callback) {
|
function processTextWithoutLast(text, callback) {
|
||||||
var tagNamesToAdd = text.split(/\s+/);
|
var tagNamesToAdd = explodeText(text);
|
||||||
var lastTagName = tagNamesToAdd.pop();
|
var lastTagName = tagNamesToAdd.pop();
|
||||||
_.map(tagNamesToAdd, function(tagName) { callback(tagName); });
|
_.map(tagNamesToAdd, function(tagName) { callback(tagName); });
|
||||||
$input.val(lastTagName);
|
$input.val(lastTagName);
|
||||||
|
|
Loading…
Reference in a new issue