0

ボタンをクリックしてイベントをトリガーしていますが、機能していません....原因がわかりません..

<div class="popOverProgressInsideRightDiv">
        <button id="popOverPause" class="btn btn-mini btn-gray btn-right">Pause</button>
    </div>


render : function() {
var compiledTemplate = Handlebars.compile(aTemplate);

$('#popOverPause').on('click', this.handlePausePress);

this.delegateEvents();

},
handlePausePress : function(event) {
alert("here");
}
4

1 に答える 1

2

十分な情報を提供していませんが、ページの読み込み中にbutton利用できずDOM、特定の時点で動的に挿入されているようです。この場合、次のような委任されたイベントハンドラーが必要です。

$(document).on('click', '.popOverProgressInsideRightDiv #popOverPause', this.handlePausePress);

これは単なる推測であり、それが機能するかどうかわからない場合は、より多くのコードを投稿して広く説明する必要があるかもしれません。

のjQueryDirect and delegated eventsのセクションを見てください。

于 2012-11-17T06:24:06.173 に答える