Reputation: 51
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>
Upvotes: 2
Views: 5726
Reputation: 27
you can do this
$( "#removeonlyinput" ).prop( "disabled", true );
don't mind the extra spaces.
Upvotes: 1
Reputation: 235
How about making the input field readonly ? By this no user can type in the input text.
$('input[type=text]').prop("readonly", true);
Upvotes: 4
Reputation: 389
Try to use beforeItemAdd
event:
$('#removeonlyinput').on('beforeItemAdd', function(event) {
event.cancel = true;
});
Upvotes: 2
Reputation: 6626
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!
Upvotes: 1