onclickフレキシグリッドで生成されたテーブルのセルのイベント ハンドラーを動的に生成しようとしています。
// ...
preProcess: function (data) {
var rows = data.rows;
for (var i = 0; i < rows.length; ++i) {
var row = rows[i];
// If and only if this condition is true, then
// row.cell[0] must be converted into a hyperlink.
if (row.cell[1] != '0') {
// I don't want to use the href attribute, because that would
// force me to define a non-anonymous function.
row.cell[0] = '<a href="javascript:void(0)" id="E'
+ i + '">' + row.cell[0] + '</a>';
// So I'm going to try assigning the onclick attribute.
$('#E' + i).click(function () {
window.open('doc.php?q=' + this.id, 'D' + this.id,
'menubar=0,toolbar=0,directories=0,location=0,status=0,' +
'resizable=0,scrollbars=0,width=600,height=300');
});
$('#E' + i).click().id = row.cell[4];
}
}
return data;
}
// ...
ただし、生成されたハイパーリンクをクリックしても機能しません。どうしたの?閉鎖の私の使用?タグは属性<a>を受け入れませんか?onclick
注: jQuery を使い始めて以来、私のポリシーはすべての関数は無名関数にすることです。通常の機能を使用することを提案しないでください。