From 09d4f4b47bccbb0334cf7058198875885add0495 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Mon, 2 Jun 2014 13:10:52 -0400 Subject: [PATCH] leaving tags box will create tag --- public/src/modules/composer/tags.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/public/src/modules/composer/tags.js b/public/src/modules/composer/tags.js index e1c1ce7e5d..f7976e7788 100644 --- a/public/src/modules/composer/tags.js +++ b/public/src/modules/composer/tags.js @@ -35,18 +35,25 @@ define('composer/tags', function() { select: function(event, ui) { // when autocomplete is selected from the dropdown simulate a enter key down to turn it into a tag // http://stackoverflow.com/a/3276819/583363 - var e = jQuery.Event('keydown'); - e.which = 13; - e.keyCode = 13; - setTimeout(function() { - input.trigger(e); - }, 100); + triggerEnter(input); } }); input.attr('tabIndex', tagEl.attr('tabIndex')); + input.on('blur', function() { + triggerEnter(input); + }) }; + function triggerEnter(input) { + var e = jQuery.Event('keydown'); + e.which = 13; + e.keyCode = 13; + setTimeout(function() { + input.trigger(e); + }, 100); + } + function addTags(tags, tagEl) { if (tags && tags.length) { for(var i=0; i