click
jQuery でハンドラーをバインドする HTML メニュー オプションがあります。
var xyz = {
getMainContainerSelector: function () {
return '.container#main';
},
bindMenuOptions: function () {
$('#menu_outcome_list').bind('click', function() {
// inject template
$(this.getMainContainerSelector()).html(ich.outcomeListTemplate({}));
// load datatable
$('#outcomes').dataTable({
"bServerSide": true,
'sPaginationType': 'bootstrap',
"sAjaxSource": '../php/client/json.php?type=outcomes'
});
});
},
...
}
次の行に問題があります。
$(this.getMainContainerSelector()).html(ich.outcomeListTemplate({}));
コンテキストの問題だと思います。つまり、bind 関数内では、もはやでthis
はxyz
なく、('#menu_outcome_list') HTML 要素です。私がやりたいことはxyz
、バインド関数内から 's メソッドを呼び出すことです。