今天使用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