HTML and CSS Reference
In-Depth Information
// TODO: This application has been reactivated from suspension.
// Restore application state here.
app.oncheckpoint=function (eventObject) {
// TODO: This application is about to be suspended. Save any state
// that needs to persist across suspensions here. You might use the
// WinJS.Application.sessionState object, which is automatically
// saved and restored across suspension. If you need to complete an
// asynchronous operation before your application is suspended, call
// eventObject.setPromise().
I have not made any changes to this file aside from reformatting the code so that it fits on
the page. This is where Metro apps depart from the standard web app environment and we
start to see some of the Windows API poke through. Metro apps have a life cycle that is more
complex than a web app, and the code added to default.js by Visual Studio provides some
basic support for handling different application states. It isn't as bad as it looks, and I'll explain
what you need to know about the Metro app life cycle, and how to respond to it, in Chapter 5 .
usinG your fAvoriTe JAvAscripT
librAries WiTh MeTro
By this point, you will have realized that a lot of your experience in web app
development is directly transferable to the world of Metro development. You can get
a head start on your Metro projects by using your favorite JavaScript libraries. I am
a huge fan of jQuery, for example, as anyone who has read my Pro jQuery topic will
know. For the most part, you shouldn't have any problems using well-written libraries
as long as you avoid areas where Metro follows a different model than mainstream
browsers. So, for example, jQuery works well in Metro apps, but be careful when using
the ready event. In a Metro app, you need to respond directly to the life-cycle events.
Another area to avoid is asynchronous script loading; I have had some problems in this
area with the Windows 8 Consumer Preview, and it is simpler just to load your code
using a regular script element.
There are some libraries, however, that it just doesn't make much sense to use. Examples
include user interface toolkits such as jQuery UI and jQuery Mobile. You can make these
work in Metro, but you end up with an application that doesn't follow the distinctive Metro
style and that may not respond to touch events in quite the same way as other Metro apps.
As a general guide, I recommend you get used to the capabilities of the WinJS API before
you start using your favorite JavaScript packages. Microsoft has provided a reasonably solid
Search WWH ::

Custom Search