Bootstrap tagsinput Can't add objects when itemValue option is not set












6















I've seen this question Bootstrap tagsinput add tag with id and value, but the solution is not working for me:



What I'm finding is that in order to get the input box recognising tags that I type in, I either have to have data-role = tagsinput OR call $("input").tagsinput().



eg. This works for recognising tags with no data-role:



$('#meeting-tags').tagsinput();
$('#meeting-tags').tagsinput({
allowDuplicates: false,
itemValue: 'id', // this will be used to set id of tag
itemText: 'label' // this will be used to set text of tag
});


But this does not:



$('#meeting-tags').tagsinput({
allowDuplicates: false,
itemValue: 'id', // this will be used to set id of tag
itemText: 'label' // this will be used to set text of tag
});


However, if I want to add items via javascript then it will only work if I neither have data-role nor have an initial call. The error is Can't add objects when itemValue option is not set



eg. this works but now it doesn't recognise tags:



$('#meeting-tags').tagsinput({
allowDuplicates: false,
itemValue: 'id', // this will be used to set id of tag
itemText: 'label' // this will be used to set text of tag
});
$('#meeting-tags').tagsinput('add', { id: 'tag id', label: 'tag lable' });


but this does not but now it recognises tags again:



$('#meeting-tags').tagsinput();
$('#meeting-tags').tagsinput({
allowDuplicates: false,
itemValue: 'id', // this will be used to set id of tag
itemText: 'label' // this will be used to set text of tag
});
$('#meeting-tags').tagsinput('add', { id: 'tag id', label: 'tag lable' });


There must surely be a way of BOTH being able to recognise tags and add items?










share|improve this question

























  • Hello, can you please share the solution for this case as I have the exact case, thanks in advance.

    – gasser
    Sep 26 '16 at 23:09
















6















I've seen this question Bootstrap tagsinput add tag with id and value, but the solution is not working for me:



What I'm finding is that in order to get the input box recognising tags that I type in, I either have to have data-role = tagsinput OR call $("input").tagsinput().



eg. This works for recognising tags with no data-role:



$('#meeting-tags').tagsinput();
$('#meeting-tags').tagsinput({
allowDuplicates: false,
itemValue: 'id', // this will be used to set id of tag
itemText: 'label' // this will be used to set text of tag
});


But this does not:



$('#meeting-tags').tagsinput({
allowDuplicates: false,
itemValue: 'id', // this will be used to set id of tag
itemText: 'label' // this will be used to set text of tag
});


However, if I want to add items via javascript then it will only work if I neither have data-role nor have an initial call. The error is Can't add objects when itemValue option is not set



eg. this works but now it doesn't recognise tags:



$('#meeting-tags').tagsinput({
allowDuplicates: false,
itemValue: 'id', // this will be used to set id of tag
itemText: 'label' // this will be used to set text of tag
});
$('#meeting-tags').tagsinput('add', { id: 'tag id', label: 'tag lable' });


but this does not but now it recognises tags again:



$('#meeting-tags').tagsinput();
$('#meeting-tags').tagsinput({
allowDuplicates: false,
itemValue: 'id', // this will be used to set id of tag
itemText: 'label' // this will be used to set text of tag
});
$('#meeting-tags').tagsinput('add', { id: 'tag id', label: 'tag lable' });


There must surely be a way of BOTH being able to recognise tags and add items?










share|improve this question

























  • Hello, can you please share the solution for this case as I have the exact case, thanks in advance.

    – gasser
    Sep 26 '16 at 23:09














6












6








6


1






I've seen this question Bootstrap tagsinput add tag with id and value, but the solution is not working for me:



What I'm finding is that in order to get the input box recognising tags that I type in, I either have to have data-role = tagsinput OR call $("input").tagsinput().



eg. This works for recognising tags with no data-role:



$('#meeting-tags').tagsinput();
$('#meeting-tags').tagsinput({
allowDuplicates: false,
itemValue: 'id', // this will be used to set id of tag
itemText: 'label' // this will be used to set text of tag
});


But this does not:



$('#meeting-tags').tagsinput({
allowDuplicates: false,
itemValue: 'id', // this will be used to set id of tag
itemText: 'label' // this will be used to set text of tag
});


However, if I want to add items via javascript then it will only work if I neither have data-role nor have an initial call. The error is Can't add objects when itemValue option is not set



eg. this works but now it doesn't recognise tags:



$('#meeting-tags').tagsinput({
allowDuplicates: false,
itemValue: 'id', // this will be used to set id of tag
itemText: 'label' // this will be used to set text of tag
});
$('#meeting-tags').tagsinput('add', { id: 'tag id', label: 'tag lable' });


but this does not but now it recognises tags again:



$('#meeting-tags').tagsinput();
$('#meeting-tags').tagsinput({
allowDuplicates: false,
itemValue: 'id', // this will be used to set id of tag
itemText: 'label' // this will be used to set text of tag
});
$('#meeting-tags').tagsinput('add', { id: 'tag id', label: 'tag lable' });


There must surely be a way of BOTH being able to recognise tags and add items?










share|improve this question
















I've seen this question Bootstrap tagsinput add tag with id and value, but the solution is not working for me:



What I'm finding is that in order to get the input box recognising tags that I type in, I either have to have data-role = tagsinput OR call $("input").tagsinput().



eg. This works for recognising tags with no data-role:



$('#meeting-tags').tagsinput();
$('#meeting-tags').tagsinput({
allowDuplicates: false,
itemValue: 'id', // this will be used to set id of tag
itemText: 'label' // this will be used to set text of tag
});


But this does not:



$('#meeting-tags').tagsinput({
allowDuplicates: false,
itemValue: 'id', // this will be used to set id of tag
itemText: 'label' // this will be used to set text of tag
});


However, if I want to add items via javascript then it will only work if I neither have data-role nor have an initial call. The error is Can't add objects when itemValue option is not set



eg. this works but now it doesn't recognise tags:



$('#meeting-tags').tagsinput({
allowDuplicates: false,
itemValue: 'id', // this will be used to set id of tag
itemText: 'label' // this will be used to set text of tag
});
$('#meeting-tags').tagsinput('add', { id: 'tag id', label: 'tag lable' });


but this does not but now it recognises tags again:



$('#meeting-tags').tagsinput();
$('#meeting-tags').tagsinput({
allowDuplicates: false,
itemValue: 'id', // this will be used to set id of tag
itemText: 'label' // this will be used to set text of tag
});
$('#meeting-tags').tagsinput('add', { id: 'tag id', label: 'tag lable' });


There must surely be a way of BOTH being able to recognise tags and add items?







twitter-bootstrap bootstrap-tags-input






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 23 '17 at 12:34









Community

11




11










asked Aug 10 '15 at 17:52









PhoebeBPhoebeB

5,49174665




5,49174665













  • Hello, can you please share the solution for this case as I have the exact case, thanks in advance.

    – gasser
    Sep 26 '16 at 23:09



















  • Hello, can you please share the solution for this case as I have the exact case, thanks in advance.

    – gasser
    Sep 26 '16 at 23:09

















Hello, can you please share the solution for this case as I have the exact case, thanks in advance.

– gasser
Sep 26 '16 at 23:09





Hello, can you please share the solution for this case as I have the exact case, thanks in advance.

– gasser
Sep 26 '16 at 23:09












6 Answers
6






active

oldest

votes


















4














I was getting the same issue ("itemValue not set") and checked the plugin and it seems the parameter 'options' in the constructor for the tagsinput is not being set even if you initialize it.






/**
* Constructor function
*/
function TagsInput(element, options) {





What I did was put a random string next to the data-role definition in the tag like so, to force it to have that value in the options parameter:






<input type="text" id="mytags" value="" data-role="tagsinput sometext" />





then did this:






var mytagsinput = $('#mytags');

//initialize
mytagsinput.tagsinput({
itemValue: 'id',
itemText: 'text',
});

//add my tags object
mytagsinput.tagsinput('add', { id: 1, text: 'mytext});





And it worked for me. Hope this helps






share|improve this answer
























  • This worked for me as well.

    – biddano
    Dec 24 '18 at 21:59



















3














I found another workaround.



Search the string "Can't add objects when itemValue option is not set" into the tagsinput.js file. You will find it inside the add function of the plugin:



// Throw an error when trying to add an object while the itemValue option was not set
if (typeof item === "object" && !self.objectItems){
throw("Can't add objects when itemValue option is not set");
}


I just force the item to be from object to string:



// Throw an error when trying to add an object while the itemValue option was not set
if (typeof item === "object" && !self.objectItems){
//throw("Can't add objects when itemValue option is not set");
item = $.trim(item.name);
}


This seems to perfectly work :). Hope this help.






share|improve this answer































    1














    initialize tags input like



     $('.div-tag').tagsinput({
    allowDuplicates: false,
    itemValue: 'id', // this will be used to set id of tag
    itemText: 'label' // this will be used to set text of tag
    });


    To add dynamic tag



    $('.div-tag').tagsinput('add', { id: 'tag id', label: 'tag lable' });


    That's it;






    share|improve this answer































      0














      From de documentation of tagsinput: This is only possible when using string as tags. When itemValue option is set, this option will be ignored.



      https://bootstrap-tagsinput.github.io/bootstrap-tagsinput/examples/






      share|improve this answer































        0














        You can just delete data-role in your input tag. It will init before your javascript which has real options.



        <input type="text" id="mytags" value=""





        share|improve this answer

































          -2














          ok, so I figure this out I think. you must remove the data-role="tagsinput" when calling



          $('.div-tag').tagsinput({
          allowDuplicates: false,
          itemValue: 'id', // this will be used to set id of tag
          itemText: 'label' // this will be used to set text of tag
          });


          I think this creates a conflict. so remove the data-role from the input and then use the tag as in Joe's answer.



          $('.div-tag').tagsinput('add', { id: 'tag id', label: 'tag lable' });





          share|improve this answer
























          • -1 because it'd be more useful if you showed how to remove data-role="tagsinput" since that is the solution you are suggesting.

            – lwdthe1
            Dec 2 '17 at 19:07













          • I was going to help. Was*

            – Juan Zamora
            Dec 3 '17 at 3:25













          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f31926025%2fbootstrap-tagsinput-cant-add-objects-when-itemvalue-option-is-not-set%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          6 Answers
          6






          active

          oldest

          votes








          6 Answers
          6






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          4














          I was getting the same issue ("itemValue not set") and checked the plugin and it seems the parameter 'options' in the constructor for the tagsinput is not being set even if you initialize it.






          /**
          * Constructor function
          */
          function TagsInput(element, options) {





          What I did was put a random string next to the data-role definition in the tag like so, to force it to have that value in the options parameter:






          <input type="text" id="mytags" value="" data-role="tagsinput sometext" />





          then did this:






          var mytagsinput = $('#mytags');

          //initialize
          mytagsinput.tagsinput({
          itemValue: 'id',
          itemText: 'text',
          });

          //add my tags object
          mytagsinput.tagsinput('add', { id: 1, text: 'mytext});





          And it worked for me. Hope this helps






          share|improve this answer
























          • This worked for me as well.

            – biddano
            Dec 24 '18 at 21:59
















          4














          I was getting the same issue ("itemValue not set") and checked the plugin and it seems the parameter 'options' in the constructor for the tagsinput is not being set even if you initialize it.






          /**
          * Constructor function
          */
          function TagsInput(element, options) {





          What I did was put a random string next to the data-role definition in the tag like so, to force it to have that value in the options parameter:






          <input type="text" id="mytags" value="" data-role="tagsinput sometext" />





          then did this:






          var mytagsinput = $('#mytags');

          //initialize
          mytagsinput.tagsinput({
          itemValue: 'id',
          itemText: 'text',
          });

          //add my tags object
          mytagsinput.tagsinput('add', { id: 1, text: 'mytext});





          And it worked for me. Hope this helps






          share|improve this answer
























          • This worked for me as well.

            – biddano
            Dec 24 '18 at 21:59














          4












          4








          4







          I was getting the same issue ("itemValue not set") and checked the plugin and it seems the parameter 'options' in the constructor for the tagsinput is not being set even if you initialize it.






          /**
          * Constructor function
          */
          function TagsInput(element, options) {





          What I did was put a random string next to the data-role definition in the tag like so, to force it to have that value in the options parameter:






          <input type="text" id="mytags" value="" data-role="tagsinput sometext" />





          then did this:






          var mytagsinput = $('#mytags');

          //initialize
          mytagsinput.tagsinput({
          itemValue: 'id',
          itemText: 'text',
          });

          //add my tags object
          mytagsinput.tagsinput('add', { id: 1, text: 'mytext});





          And it worked for me. Hope this helps






          share|improve this answer













          I was getting the same issue ("itemValue not set") and checked the plugin and it seems the parameter 'options' in the constructor for the tagsinput is not being set even if you initialize it.






          /**
          * Constructor function
          */
          function TagsInput(element, options) {





          What I did was put a random string next to the data-role definition in the tag like so, to force it to have that value in the options parameter:






          <input type="text" id="mytags" value="" data-role="tagsinput sometext" />





          then did this:






          var mytagsinput = $('#mytags');

          //initialize
          mytagsinput.tagsinput({
          itemValue: 'id',
          itemText: 'text',
          });

          //add my tags object
          mytagsinput.tagsinput('add', { id: 1, text: 'mytext});





          And it worked for me. Hope this helps






          /**
          * Constructor function
          */
          function TagsInput(element, options) {





          /**
          * Constructor function
          */
          function TagsInput(element, options) {





          <input type="text" id="mytags" value="" data-role="tagsinput sometext" />





          <input type="text" id="mytags" value="" data-role="tagsinput sometext" />





          var mytagsinput = $('#mytags');

          //initialize
          mytagsinput.tagsinput({
          itemValue: 'id',
          itemText: 'text',
          });

          //add my tags object
          mytagsinput.tagsinput('add', { id: 1, text: 'mytext});





          var mytagsinput = $('#mytags');

          //initialize
          mytagsinput.tagsinput({
          itemValue: 'id',
          itemText: 'text',
          });

          //add my tags object
          mytagsinput.tagsinput('add', { id: 1, text: 'mytext});






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Feb 26 '18 at 21:19









          jasavjasav

          411




          411













          • This worked for me as well.

            – biddano
            Dec 24 '18 at 21:59



















          • This worked for me as well.

            – biddano
            Dec 24 '18 at 21:59

















          This worked for me as well.

          – biddano
          Dec 24 '18 at 21:59





          This worked for me as well.

          – biddano
          Dec 24 '18 at 21:59













          3














          I found another workaround.



          Search the string "Can't add objects when itemValue option is not set" into the tagsinput.js file. You will find it inside the add function of the plugin:



          // Throw an error when trying to add an object while the itemValue option was not set
          if (typeof item === "object" && !self.objectItems){
          throw("Can't add objects when itemValue option is not set");
          }


          I just force the item to be from object to string:



          // Throw an error when trying to add an object while the itemValue option was not set
          if (typeof item === "object" && !self.objectItems){
          //throw("Can't add objects when itemValue option is not set");
          item = $.trim(item.name);
          }


          This seems to perfectly work :). Hope this help.






          share|improve this answer




























            3














            I found another workaround.



            Search the string "Can't add objects when itemValue option is not set" into the tagsinput.js file. You will find it inside the add function of the plugin:



            // Throw an error when trying to add an object while the itemValue option was not set
            if (typeof item === "object" && !self.objectItems){
            throw("Can't add objects when itemValue option is not set");
            }


            I just force the item to be from object to string:



            // Throw an error when trying to add an object while the itemValue option was not set
            if (typeof item === "object" && !self.objectItems){
            //throw("Can't add objects when itemValue option is not set");
            item = $.trim(item.name);
            }


            This seems to perfectly work :). Hope this help.






            share|improve this answer


























              3












              3








              3







              I found another workaround.



              Search the string "Can't add objects when itemValue option is not set" into the tagsinput.js file. You will find it inside the add function of the plugin:



              // Throw an error when trying to add an object while the itemValue option was not set
              if (typeof item === "object" && !self.objectItems){
              throw("Can't add objects when itemValue option is not set");
              }


              I just force the item to be from object to string:



              // Throw an error when trying to add an object while the itemValue option was not set
              if (typeof item === "object" && !self.objectItems){
              //throw("Can't add objects when itemValue option is not set");
              item = $.trim(item.name);
              }


              This seems to perfectly work :). Hope this help.






              share|improve this answer













              I found another workaround.



              Search the string "Can't add objects when itemValue option is not set" into the tagsinput.js file. You will find it inside the add function of the plugin:



              // Throw an error when trying to add an object while the itemValue option was not set
              if (typeof item === "object" && !self.objectItems){
              throw("Can't add objects when itemValue option is not set");
              }


              I just force the item to be from object to string:



              // Throw an error when trying to add an object while the itemValue option was not set
              if (typeof item === "object" && !self.objectItems){
              //throw("Can't add objects when itemValue option is not set");
              item = $.trim(item.name);
              }


              This seems to perfectly work :). Hope this help.







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Dec 24 '17 at 10:39









              Francesco MineoFrancesco Mineo

              3342423




              3342423























                  1














                  initialize tags input like



                   $('.div-tag').tagsinput({
                  allowDuplicates: false,
                  itemValue: 'id', // this will be used to set id of tag
                  itemText: 'label' // this will be used to set text of tag
                  });


                  To add dynamic tag



                  $('.div-tag').tagsinput('add', { id: 'tag id', label: 'tag lable' });


                  That's it;






                  share|improve this answer




























                    1














                    initialize tags input like



                     $('.div-tag').tagsinput({
                    allowDuplicates: false,
                    itemValue: 'id', // this will be used to set id of tag
                    itemText: 'label' // this will be used to set text of tag
                    });


                    To add dynamic tag



                    $('.div-tag').tagsinput('add', { id: 'tag id', label: 'tag lable' });


                    That's it;






                    share|improve this answer


























                      1












                      1








                      1







                      initialize tags input like



                       $('.div-tag').tagsinput({
                      allowDuplicates: false,
                      itemValue: 'id', // this will be used to set id of tag
                      itemText: 'label' // this will be used to set text of tag
                      });


                      To add dynamic tag



                      $('.div-tag').tagsinput('add', { id: 'tag id', label: 'tag lable' });


                      That's it;






                      share|improve this answer













                      initialize tags input like



                       $('.div-tag').tagsinput({
                      allowDuplicates: false,
                      itemValue: 'id', // this will be used to set id of tag
                      itemText: 'label' // this will be used to set text of tag
                      });


                      To add dynamic tag



                      $('.div-tag').tagsinput('add', { id: 'tag id', label: 'tag lable' });


                      That's it;







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered May 21 '16 at 16:44









                      JoeJoe

                      1,0141010




                      1,0141010























                          0














                          From de documentation of tagsinput: This is only possible when using string as tags. When itemValue option is set, this option will be ignored.



                          https://bootstrap-tagsinput.github.io/bootstrap-tagsinput/examples/






                          share|improve this answer




























                            0














                            From de documentation of tagsinput: This is only possible when using string as tags. When itemValue option is set, this option will be ignored.



                            https://bootstrap-tagsinput.github.io/bootstrap-tagsinput/examples/






                            share|improve this answer


























                              0












                              0








                              0







                              From de documentation of tagsinput: This is only possible when using string as tags. When itemValue option is set, this option will be ignored.



                              https://bootstrap-tagsinput.github.io/bootstrap-tagsinput/examples/






                              share|improve this answer













                              From de documentation of tagsinput: This is only possible when using string as tags. When itemValue option is set, this option will be ignored.



                              https://bootstrap-tagsinput.github.io/bootstrap-tagsinput/examples/







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered May 4 '16 at 7:47









                              markcanalsmarkcanals

                              11




                              11























                                  0














                                  You can just delete data-role in your input tag. It will init before your javascript which has real options.



                                  <input type="text" id="mytags" value=""





                                  share|improve this answer






























                                    0














                                    You can just delete data-role in your input tag. It will init before your javascript which has real options.



                                    <input type="text" id="mytags" value=""





                                    share|improve this answer




























                                      0












                                      0








                                      0







                                      You can just delete data-role in your input tag. It will init before your javascript which has real options.



                                      <input type="text" id="mytags" value=""





                                      share|improve this answer















                                      You can just delete data-role in your input tag. It will init before your javascript which has real options.



                                      <input type="text" id="mytags" value=""






                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited Nov 23 '18 at 4:58









                                      jkdev

                                      5,16253364




                                      5,16253364










                                      answered Nov 23 '18 at 2:56









                                      Jak LiaoJak Liao

                                      364




                                      364























                                          -2














                                          ok, so I figure this out I think. you must remove the data-role="tagsinput" when calling



                                          $('.div-tag').tagsinput({
                                          allowDuplicates: false,
                                          itemValue: 'id', // this will be used to set id of tag
                                          itemText: 'label' // this will be used to set text of tag
                                          });


                                          I think this creates a conflict. so remove the data-role from the input and then use the tag as in Joe's answer.



                                          $('.div-tag').tagsinput('add', { id: 'tag id', label: 'tag lable' });





                                          share|improve this answer
























                                          • -1 because it'd be more useful if you showed how to remove data-role="tagsinput" since that is the solution you are suggesting.

                                            – lwdthe1
                                            Dec 2 '17 at 19:07













                                          • I was going to help. Was*

                                            – Juan Zamora
                                            Dec 3 '17 at 3:25


















                                          -2














                                          ok, so I figure this out I think. you must remove the data-role="tagsinput" when calling



                                          $('.div-tag').tagsinput({
                                          allowDuplicates: false,
                                          itemValue: 'id', // this will be used to set id of tag
                                          itemText: 'label' // this will be used to set text of tag
                                          });


                                          I think this creates a conflict. so remove the data-role from the input and then use the tag as in Joe's answer.



                                          $('.div-tag').tagsinput('add', { id: 'tag id', label: 'tag lable' });





                                          share|improve this answer
























                                          • -1 because it'd be more useful if you showed how to remove data-role="tagsinput" since that is the solution you are suggesting.

                                            – lwdthe1
                                            Dec 2 '17 at 19:07













                                          • I was going to help. Was*

                                            – Juan Zamora
                                            Dec 3 '17 at 3:25
















                                          -2












                                          -2








                                          -2







                                          ok, so I figure this out I think. you must remove the data-role="tagsinput" when calling



                                          $('.div-tag').tagsinput({
                                          allowDuplicates: false,
                                          itemValue: 'id', // this will be used to set id of tag
                                          itemText: 'label' // this will be used to set text of tag
                                          });


                                          I think this creates a conflict. so remove the data-role from the input and then use the tag as in Joe's answer.



                                          $('.div-tag').tagsinput('add', { id: 'tag id', label: 'tag lable' });





                                          share|improve this answer













                                          ok, so I figure this out I think. you must remove the data-role="tagsinput" when calling



                                          $('.div-tag').tagsinput({
                                          allowDuplicates: false,
                                          itemValue: 'id', // this will be used to set id of tag
                                          itemText: 'label' // this will be used to set text of tag
                                          });


                                          I think this creates a conflict. so remove the data-role from the input and then use the tag as in Joe's answer.



                                          $('.div-tag').tagsinput('add', { id: 'tag id', label: 'tag lable' });






                                          share|improve this answer












                                          share|improve this answer



                                          share|improve this answer










                                          answered Jan 16 '17 at 23:05









                                          Juan ZamoraJuan Zamora

                                          328411




                                          328411













                                          • -1 because it'd be more useful if you showed how to remove data-role="tagsinput" since that is the solution you are suggesting.

                                            – lwdthe1
                                            Dec 2 '17 at 19:07













                                          • I was going to help. Was*

                                            – Juan Zamora
                                            Dec 3 '17 at 3:25





















                                          • -1 because it'd be more useful if you showed how to remove data-role="tagsinput" since that is the solution you are suggesting.

                                            – lwdthe1
                                            Dec 2 '17 at 19:07













                                          • I was going to help. Was*

                                            – Juan Zamora
                                            Dec 3 '17 at 3:25



















                                          -1 because it'd be more useful if you showed how to remove data-role="tagsinput" since that is the solution you are suggesting.

                                          – lwdthe1
                                          Dec 2 '17 at 19:07







                                          -1 because it'd be more useful if you showed how to remove data-role="tagsinput" since that is the solution you are suggesting.

                                          – lwdthe1
                                          Dec 2 '17 at 19:07















                                          I was going to help. Was*

                                          – Juan Zamora
                                          Dec 3 '17 at 3:25







                                          I was going to help. Was*

                                          – Juan Zamora
                                          Dec 3 '17 at 3:25




















                                          draft saved

                                          draft discarded




















































                                          Thanks for contributing an answer to Stack Overflow!


                                          • Please be sure to answer the question. Provide details and share your research!

                                          But avoid



                                          • Asking for help, clarification, or responding to other answers.

                                          • Making statements based on opinion; back them up with references or personal experience.


                                          To learn more, see our tips on writing great answers.




                                          draft saved


                                          draft discarded














                                          StackExchange.ready(
                                          function () {
                                          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f31926025%2fbootstrap-tagsinput-cant-add-objects-when-itemvalue-option-is-not-set%23new-answer', 'question_page');
                                          }
                                          );

                                          Post as a guest















                                          Required, but never shown





















































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown

































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown







                                          Popular posts from this blog

                                          "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

                                          Alcedinidae

                                          Origin of the phrase “under your belt”?