tag-it
tag-it copied to clipboard
Double click on tag to edit it
Is it possible (possibly already implemented somewhere?) to double-click on a tag to edit it? (be able to change spelling if typos, etc.)
+1
need to edit tag!
+1
HTML
<input name="tags" id="singleFieldTags2" value="" class="tagit-hidden-field">
JS `
$(document).ready(function() {
var temp;
$("#singleFieldTags2").tagit({
onTagClicked: function(event, ui) {
var elem = $(ui.tag);
var input = $('<input type="text" id="replaceInput" value="'+ ui.tagLabel + '" />');
temp = ui.tagLabel;
input.bind('blur',function(){
var instance = $("#singleFieldTags2").data("tagit");
$(this).closest('.tagit-label').empty().append($(this).val());
var oldValue = temp;
var tags = instance.assignedTags();
for(var i = 0;i < tags.length;i++){
if (tags[i] === oldValue){
tags[i] = $(this).val();
}
}
instance._updateSingleTagsField(tags);
});
elem.find('.tagit-label').empty().append(input);
input.focus();
}
});
});
`
It's not really pretty and it can be largely improved, but it works...
A correction, in this part the correct way that worked for me was this
...
var instance = $("#singleFieldTags2").tagit('instance');
var instance = $("#singleFieldTags2").data("tagit"); // This not work for me
...