Delete Twitter from text field

I am trying to disable all text fields in my form. One of these boxes has typeahead. When I do this:

$(#textbox).attr('disabled', true); 

It is no longer included, but the color does not switch, like all other text fields, when they become disabled.

I believe this is related to typeahead twitter, and I wonder if there is a way around it. Does anyone know how to override the background color in a text box or completely remove the text box when the text box is disabled?

I tried .unbind() and .addClass("greyBackground") , but none of them seem to do the trick.

+6
source share
2 answers

If you do not need to support typeahead.js functionality and textarea disabled, you can destroy typeahead as follows:

 $('#textbox').typeahead('destroy'); 

This will reset / remove any attributes / styles that can be added to the typeahead.js file. If you later want to add typeahead.js functionality, you can reinitialize it with:

 $('#textbox').typeahead({ /* configs */ }); 

In addition, typeahead.js does not support textarea elements out of the box, so if you are not using a forked version, you should not assume that typeahead.js will work as expected.

+13
source

Bootstrap 2.2.2 lacks the .typeahead('destroy') function, so below it removes all listeners to which it was previously bound and the DOM element it created.

 $('#textbox').off() .data('typeahead') .$menu .off() .remove(); 
+1
source

Source: https://habr.com/ru/post/948015/


All Articles