2013-11-21 30 views
3

使用jQuery UI插件Tag-it,可以與字符的數百如進入標籤:最大數量標籤,它

「loremipsumdolorsitametconsecteturadipisicingelitseddoeiu​​smodtemporincididuntutlaboreetdoloremagnaaliquautenimadminimveniamquisnostrudexercitationullamco」

我試圖設置每個標籤允許的最大字符數。到目前爲止,我嘗試了tagLimit,但這限制了允許的標籤總數,但是限制了每個標籤的字符數限制。

有誰知道我可以設置每個標籤允許的字符數限制嗎?

$(document).ready(function() { 
    $("#tags").tagit({ 
     tagLimit: 5, 
     allowSpaces: true, 
     placeholderText: 'Tags' 
    }); 
}); 
+0

謝謝kingkero,爲編輯 – henrywright

+0

歡迎您。但我恐怕我不能幫你。另外我相信你必須編輯'tag-it.js'來自己實現這個功能 - 或者使用另一個插件來標記 – kero

+0

我認爲可能需要編輯tag-it.js。我不想使用另一個插件,因爲它提供了一些我非常喜歡的功能。希望有人能幫助。 – henrywright

回答

0

我知道這是不是最好的解決辦法,但我編輯了_cleanedInput方法來削減每個標籤100個字符的最大值(在我的應用我懷疑會有超過100個字符,甚至還沒有接近50任何標籤!)。

在插件中,我改變了這一點:

_cleanedInput: function() { 
    return $.trim(this.tagInput.val().replace(/^"(.*)"$/, '$1')); 
}, 

要:

_cleanedInput : function() { 
    return $.trim(this.tagInput.val().replace(/^"(.*)"$/, "$1")).substr(0, 100); 
},