最終更新:2014-01-05 (日) 14:28:44 (3762d)  

jQuery Plugin tagedit
Top / jQuery Plugin tagedit

http://tagedit.webwork-albrecht.de/

スクリプトからタグ追加するパッチ

  • 末尾を下記のように変更。
  • http://stackoverflow.com/questions/12103051/jquery-tagedit-by-webworka-adding-items-programmatically
    			return new Array(isNew, autoCompleteId);
    		}
    
    		
    		
    		this.addNew = function (value) {
    			var oldValue = (typeof value != 'undefined' && value.length > 0);
    			var checkAutocomplete = oldValue == true? false : true;
    			// check if the Value ist new
    			console.log(value);
    			var isNewResult = isNew(value, checkAutocomplete);
    			if(isNewResult[0] === true || (isNewResult[0] === false && typeof isNewResult[1] == 'string')) {
    				console.log('NEW: ' + value);
    				if(options.allowAdd == true) {
    					// Make a new tag in front the input
    					html = '<li class="tagedit-listelement tagedit-listelement-old">';
    					html += '<span dir="'+options.direction+'">' + value + '</span>';
    					var name = baseName + '[]';
    					html += '<input type="hidden" name="'+name+'" value="'+value+'" />';
    					html += '<a class="tagedit-close" title="'+options.texts.removeLinkTitle+'">x</a>';
    					html += '</li>';
    
    					$('.tagedit-listelement-new').before(html);
    				}
    			} else { console.log('NOT NEW: ' + value)}
    		}
    		return this;
    	}
    })(jQuery);