それをいじってみました。http://jsfiddle.net/pDrzx/46/を参照してください。
私がしたこと:
createTag 関数を labelname で拡張します
createTag: function(labelname, value, additionalClass)
そして、ラベル作成変数でそれを呼び出しました
var label = $(this.options.onTagClicked ? '<a class="tagit-label"></a>' : '<span class="tagit-label"></span>').text(labelname);
次に、非表示の入力フィールドに数値があることを確認しました(保存目的のため)
if (this.options.singleField) {
var tags = this.assignedTags();
tags.push(value);
this._updateSingleTagsField(tags);
} else {
var escapedValue = value;
tag.append('<input type="hidden" style="display:none;" value="' + escapedValue + '" name="' + this.options.itemName + '[' + this.options.fieldName + '][]" />');
}
そして最後に、ラベル名をオートコンプリートとフォーカスに追加しました
// Autocomplete.
if (this.options.availableTags || this.options.tagSource) {
this._tagInput.autocomplete({
source: this.options.tagSource,
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.label,ui.item.value);
// Preventing the tag input to be updated with the chosen value.
return false;
},
focus: function(event, ui) {
event.preventDefault();
that.createTag(ui.item.label,ui.item.value);
}
});
不足しているものはありますが、すべての createTag メソッドでラベル名を渡すようにする必要がありますが、それほど難しくはありません:)
焦点を当てて更新(@Edwinに触発)