mdbootstrap/bootstrap-templates

Using bootstrap3 tagsinput with typeahead, how to change data-source?

fivesand opened this issue · 0 comments

Hi there,

I am using the bootstrap3 tagsinput combined with typeahead.
The idea is to update the data-source onkeypress/keyup (people typing in the input textfield)
I have done many tests to update the data-source on the go without using 'destroy', but I cannot find the way.

I notice the typeahead code has 'setSource', but I am not sure how to call it.

This is my code to init the tagsinput and typeahead:

			var places = ["Alabama","Wisconsin"];
			var places1 = ["Alabama","Wisconsin","York"];
			$(".taginput").tagsinput({
				maxTags:1,
				typeahead: {
					source: places,
				}
			});

I want to change the source to places1, so the "York" is available.

I have tried the following, but none works:

var autocomplete = $(".taginput").typeahead();
autocomplete.data('typeahead').source = places1;
					$(obj).tagsinput({
						typeahead: {
							source:places1,
							setSource:places1,
						}
					});
					$(obj).tagsinput('refresh');

How should I update the data-source without resetting the tagsinput such as 'destroy'?

Please help