!!!prototype.js HTMLとスクリプトを分離
以下のようなスクリプトを、HTML側で読み込む。
'''hoge.js'''
// Window のロード時に initDocumentを呼び出す
Event.observe(window, 'load', initDocument, false);
// 初期処理
function initDocument() {
setEventHundler();
}
// イベントハンドラをセット
function setEventHundler() {
Event.observe($('elmt1'), 'click', hndler1, false);
Event.observe($('elmt2'), 'click', hndler2, false);
}
// イベントハンドラ1
function hndler1() {
}
// イベントハンドラ2
function hndler2() {
}