HTML and CSS Reference
In-Depth Information
Listing 15.85 Expecting the message form to clear message
"test should clear form after publish": function () {
var el = this.element.getElementsByTagName("input")[0];
el.value = "NP: A vision of misery";
this.controller.handleSubmit(this.event);
assertEquals("", el.value);
}
Ideally, we would not clear the form until we know for sure the message was
sent. Unfortunately, the cometClient does not support adding a success callback
at this point, so the best we can do is clearing it immediately after having sent it and
hope for the best. The proper fix would include adding a third options argument
to cometClient and wait for success. Listing 15.86 shows the message form
controller's updated handleSubmit .
Listing 15.86 Clearing the message after publishing it
function handleSubmit(event) {
/* ... */
input.value = "";
}
It would also be nice if the message form gave focus to the input field immedi-
ately upon initializing it. I will leave doing so as an exercise.
15.6.2 Notes on Deployment
Copy over the message form and message list controllers to chapp's public di-
rectory and reload your browser. The application should now be slightly smoother
to use.
Simply copying files to deploy them is cumbersome and error prone. Addi-
tionally, serving the application with 15 individual script files is not optimal for
performance. If you installed Ruby and RubyGems to use the jstestdriver
and jsautotest tools in Chapter 3, Tools of the Trade, then you have a JavaScript
and CSS concatenator and minifier at your fingertips. Listing 15.87 shows the three
required commands to install Juicer, which will conveniently package your scripts
for deployment.
 
Search WWH ::




Custom Search