skip to Main Content

I’m going to use bootstrap tagsinput without adding new tags feature (only remove tags). How to disable adding new tags?

I’m using latest bootstrap tagsinput v0.8.0 with twitter bootstrap 3.

Here is my snippet:

<input id="removeonlyinput" type="text" value="Amsterdam,Berlin,Lisbon" data-role="tagsinput" />

<script>
$('#removeonlyinput').tagsinput({
      freeinput: false
});
</script>

5

Answers


  1. You can modify bootstrap-tagsinput.js file.

    find maxTags:, line and make it maxTags: 0,

    Then it won’t add new tags.

    In this way I achieved the functionality.
    Hope this helps!

    Login or Signup to reply.
  2. Try to use beforeItemAdd event:

    $('#removeonlyinput').on('beforeItemAdd', function(event) {
      event.cancel = true;
    });
    
    Login or Signup to reply.
  3. How about making the input field readonly ? By this no user can type in the input text.

    $('input[type=text]').prop("readonly", true);
    
    Login or Signup to reply.
  4. you can do this

    $( "#removeonlyinput" ).prop( "disabled", true );
    

    don’t mind the extra spaces.

    Login or Signup to reply.
  5. it’s not

    freeinput: false
    

    it’s

    freeInput: false
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search