Dynamically add and remove boot type

Is it possible to dynamically add and remove the dynamic bootstrap type.

In some cases, I need to provide typeahaed functionality for one text field, and you need to remove this function for the same input field in another case.

+7
source share
6 answers

I used

$('.typeahead').removeClass('dropdown-menu'); 

and

 $('.typeahead').addClass('dropdown-menu'); 

to hide this drop-down sentence.

+2
source

Yes, you can. This is pretty easy using the jquery .unbind () method

For example:

 $('.typehead').typehead(); //and then you can dynamically unbind this plugin $('.typehead').unbind(); 
+6
source

I know I'm late to the party, take off below instead of just hiding.

 $('.typeahead').typeahead('destroy'); 
+6
source

I had to use a different (and hacky) solution, because I change typeahead data every time I bind it, and could not get other answers to work. I will leave it here if someone needs it.

Remove Typeahead

 var parent = $('.typeahead').parent(); var html = parent.html(); $('.typeahead).remove(); parent.html(html); 

Add Typeahead

 $('.typehead').typehead(); 
+1
source

This code works for me.

 var typeaheadEle = $('#myTypeahead').data('typeahead'); if (typeaheadEle) {typeaheadEle.source = [];} 

where myTypeahead is the identifier of the input element.

+1
source

I found that $('.some-typeahead-parent .tt-dropdown-menu').hide(); works best for multiple data types.

0
source

All Articles