O'Reilly logo

Yii Rapid Application Development Hotshot by James R. Hamilton III, Lauren J. O'Meara

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Improving the View

There are a few mildly annoying problems with the game as we have currently implemented it. You have to click on the Guess input box to type, and then you can click on Submit or press Enter. It would be nice if we could set the input focus to the Guess input box. It would also be nice if we didn't have to press Enter, since we are only guessing one letter at a time. We can use jQuery to quickly fix this.

Engage Thrusters

Let's give the Guess text input focus when the page loads. Register a tiny piece of JavaScript to be run on POS_READY, and then give the Guess input an ID to refer to it from the JavaScript. We will use jQuery to do this because it is convenient and concise (open protected/views/hangman/play.php):

  else {

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required