複数のチェックボックスを備えたテーブルを含むjQueryダイアログボックスがあります。
$("#custom-modal").dialog({
height: 200,
modal: true,
buttons: { "OK": function () {
var table1 = $("#MainContent_rtc1_customTable").html();
alert(table1);
//$.session('mytbl', $("#customTable").val());
$.ajax({
type: "POST",
url: "MyPage.aspx/BindCustom",
data: ({ param1: table1 }),
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(errorThrown);
},
success: function (result) {
alert("success");
}
});
$(this).dialog("close");
return true;
}, "Cancel": function () {
$(this).dialog("close");
return false;
}
}
});
});
$(':checkbox').click(function () {
var $this = $(this);
if ($this.is(':checked')) {
//alert(event.target.id);
$this.attr('checked', false);
} else {
//alert(event.target.id);
$this.attr('checked', true);
}
});
チェックボックスの状態を変更した後、alert(table1);でテーブルのhtmlコードが表示されたとき。(OKボタンを押した後); すべてのチェックボックスの状態がチェックされているのがわかります。だから彼らは変わらないのです。