LoginSignup
2
2

More than 5 years have passed since last update.

Metroアプリ起動時の状態遷移 - Metro App (Javascript)

Last updated at Posted at 2012-07-06

Metro アプリ の起動時の状態遷移は以下の順でイベントハンドラがコールされる。

起動時のイベント順

  1. WinJS.Application.onloaded
  2. WinJS.Application.onactivated
  3. WinJS.Application.onready

ちなみにDOMの読み込みが終わるのは、onready のタイミングです。
なので、document.getElementBy("#itemA") など、DOM要素を操作したいときにはここ。

余談 : javascriptでのイベントリスナ登録について

js側でイベントリスナを登録するタイミングについて、以下に記載がありました。
http://msdn.microsoft.com/en-us/library/windows/apps/hh465402.aspx
ここを参照すると、 WinJS.Application.onactivated のイベントリスナで、WinJS.UI.processAll().done() 内で行うように推奨されてますね。

サンプル引用

args.setPromise(WinJS.UI.processAll().done(function () {
var button1 = document.getElementById("button1");
button1.addEventListener("click", button1Click, false);
})
);

もうちょっと詳しく見てみます。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2