Bootstrap is an open-source front-end development framework that provides a number of plugins that can be used by developers, including many templates and styles.
During the previous period, when the study was completed automatically, a problem was found in the bootstrap auto-prompt, and then the problem was solved in detail.
First of all, the company's projects are BOOTSTRAP2.
Problem Description: In the Chinese input method, when the input box that has been declared as Typeahead is entered, when the ENTER key is pressed, the existing content will not be automatically prompted.
Solution: Mainly this time the input method captures our keys will appear in Chinese input some hints, such as Sogou's words hint. Of course, there may also be a Sogou prompt box blocking our auto-complete prompt box. If the input is correct, when you press ENTER, we should have a prompt for our ideal state. But not at the moment. We look at the code snippet bootstrap about Typeahead's source discovery:
Here's how to press the key:
keyup: function (e) { switch (E.keycode) {       CASE 40:        CASE 38: case 16: case 17: case 18: break; case 9: case 13: if (!this.shown) return; this.select (); break; case 27: if (!this.shown) return; this.hide (); break; default: this.lookup ( ) } e.stoppropagation (), e.preventdefault ()}
When you look at it, you'll find that pressing ENTER here is the event of choice, and our Typeahead prompt does not select the result we want, which is obviously not what we want to do with the selection event.
Here's my revised code:
keyup: function (e) { switch (E.keycode) { case 40: case 38: case 16: case 17: case 18: break; case 9: //case 13: if (!this.shown) return; this.select (); break; case 27: if (!this.shown) return; this.hide (); break; case 13: if (!this.shown) {this.lookup (); return;} this.select (); break; default: this.lookup () } e.stoppropagation (), e.preventdefault ()}
Look at the code will find that we have removed the original processing of enter, a new branch to deal with our method. The main logic is: If the prompt box is not displayed, then we need to find the following data, display the prompt box. If it does, we execute the selection event.
Solve the problem. The main problem may be that bootstrap developers may not have faced the event of entering Chinese to perform enter, so they did not find the problem, or, BOOSTRAP3, have already been repaired.
This article is from the "Silent Chen Gui" blog, please make sure to keep this source http://snaile.blog.51cto.com/8061810/1727139
About Bootsreap automatic prompt typeahead bug