今天使用bootstrap中的tagsinput控件,碰到個小問題


我直接使用時,后台一直報Uncaught Can't add objects when itemValue option is not set錯誤,

代碼如下:

<div>
    <input id="uploadFiles" placeholder="請選擇..." data-role="tagsinput" />
</div>

  

        $("#uploadFiles").tagsinput({
            itemValue: 'id',
            itemText: 'text',
        });
        
        var test={id:'adfa',text:'fff'};
        
        $("#uploadFiles").tagsinput('add', test);

查了半天,沒找到問題所在,后來在stackoverflow發現一個相同的錯誤的帖子:

http://stackoverflow.com/questions/31926025/bootstrap-tagsinput-cant-add-objects-when-itemvalue-option-is-not-set

給了我啟發,原來是寫了data-role="tagsinput"屬性,去掉后就OK啦


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM