Bootstrap starts when the page loads as a self-executing function. By adding a new element to the DOM - by then bootstrap-tagsinput.js will not know anything about it. Thus, you will have to initialize it after adding it to the DOM document using JavaScript.
To update input tags ( Boot tags in documents ):
$('input').tagsinput('refresh');
So for you you need:
$('#addrun').click(function () { $('#addrun').before('<input type="text" ' + 'value="Amsterdam,Washington,Sydney,Beijing" '+ 'data-role="tagsinput" />');
Hope this helps! Despite the fact that above $('input') update each <input> in the entire document, so instead of the more preferred <input> you can use the .class or #ID class for faster access =)
Update:
Since koala_dev mentioned correctly in the comments, you probably won't need to initialize it with $('selector').tagsinput('refresh') , but simply:
$('#selecor').tagsinput();
.tagsinput('refresh') will usually be executed at the input of .tagsinput() , which is already initialized with the new parameters.
source share