mirror of
https://github.com/owncloud/bookmarks.git
synced 2024-12-11 12:24:10 +01:00
Fix tag-it for double event trigger on autocomplete. Apply tag-it PR: 41
This commit is contained in:
parent
43399c35b3
commit
887fdb9650
19
js/tag-it.js
19
js/tag-it.js
@ -196,8 +196,12 @@
|
|||||||
that._tagInput.autocomplete('close');
|
that._tagInput.autocomplete('close');
|
||||||
}
|
}
|
||||||
}).blur(function(e){
|
}).blur(function(e){
|
||||||
// Create a tag when the element loses focus (unless it's empty).
|
//If autocomplete is enabled and suggestion was clicked, don't add it
|
||||||
that.createTag(that._cleanedInput());
|
if (that.options.tagSource && that._tagInput.data('autocomplete-open')) {
|
||||||
|
that._cleanedInput();
|
||||||
|
} else {
|
||||||
|
that.createTag(that._cleanedInput());
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -205,16 +209,9 @@
|
|||||||
if (this.options.availableTags || this.options.tagSource) {
|
if (this.options.availableTags || this.options.tagSource) {
|
||||||
this._tagInput.autocomplete({
|
this._tagInput.autocomplete({
|
||||||
source: this.options.tagSource,
|
source: this.options.tagSource,
|
||||||
|
open: function(){that._tagInput.data('autocomplete-open', true)},
|
||||||
|
close: function(){that._tagInput.data('autocomplete-open', false)},
|
||||||
select: function(event, ui) {
|
select: function(event, ui) {
|
||||||
// Delete the last tag if we autocomplete something despite the input being empty
|
|
||||||
// This happens because the input's blur event causes the tag to be created when
|
|
||||||
// the user clicks an autocomplete item.
|
|
||||||
// The only artifact of this is that while the user holds down the mouse button
|
|
||||||
// on the selected autocomplete item, a tag is shown with the pre-autocompleted text,
|
|
||||||
// and is changed to the autocompleted text upon mouseup.
|
|
||||||
if (that._tagInput.val() === '') {
|
|
||||||
that.removeTag(that._lastTag(), false);
|
|
||||||
}
|
|
||||||
that.createTag(ui.item.value);
|
that.createTag(ui.item.value);
|
||||||
// Preventing the tag input to be updated with the chosen value.
|
// Preventing the tag input to be updated with the chosen value.
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user