私は John Resig のクラス モデル ( http://ejohn.org/blog/simple-javascript-inheritance/ ) を使用しており、次の質問があります。
以下のクラスでは、削除ダイアログを作成しています。「はい」ボタンが押されたら、機能を実行したいと思いhandleDeleteItem
ます。どうすればいいですか?「this」はダイアログを参照するため、「this.handleDeleteItem」は使用できません。
var bItem = Class.extend({
init: function (type) {
this.id = type + "-" + getNewId();
},
registerDelete: function () {
var itemId = this.id;
// Build Delete Dialog
var deleteDialog = '<div id="' + itemId + '-delete-dialog" title="Delete Item?"><p><br/><span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"></span>Are you sure you want to delete this item?</p></div>';
// Append dialog
$('#b-main').append(deleteDialog);
// Confirmation dialog
$('#' + itemId + '-delete-dialog').dialog({
buttons : {
"Yes" : this.handleDeleteItem(),
"No" : function () {
$(this).dialog("close");
}
}
});
$("#dialog").dialog("open");
},
handleDeleteItem: function () {}
});