【发布时间】:2009-03-12 18:25:07
【问题描述】:
我有一个关于 jQuery 函数的问题。我有一个功能,一旦浏览器准备好,该功能就会找到一个特定的表格,然后向它添加悬停和单击功能。
我正在尝试从 asp .net 页面中的代码调用此函数,因为一旦有人将其添加到数据库中,更新面板就会触发并检索 gridview(受文档中的函数影响的表。准备好)。当它回来时,它又是一张普通的桌子。
这里是原始函数:
$("#GridView1").find("tr").click(function(e) {
var row = jQuery(this)
//var bID = row.children("td:eq(0)").text();
$('#tbHiddenBatchID').val(row.children("td:eq(0)").text());
//Took out repetitive code, places values from table into modal
e.preventDefault();
$('#modalContentTest').modal({ position: ["25%", "5%"] });
//row.addClass('highlight');
//$('#tbEdit').val(bID);
});
//here is the function that adds hover styling
$("#GridView1").find("tr").click(function() {
return $('td', this).length && !$('table', this).length
}).css({ background: "ffffff" }).hover(
function() { $(this).css({ background: "#C1DAD7" }); },
function() {
$(this).css({ background: "#ffffff" });
});
好的,我尝试做的是创建一个函数,在 document.ready 上调用它,并在数据库更新后在后面的代码中调用它。
这就是我所做的:
function helpGrid() {
$("#GridView1").find("tr").click(function(e) {
var row = jQuery(this)
//var bID = row.children("td:eq(0)").text();
$('#tbHiddenBatchID').val(row.children("td:eq(0)").text());
//
e.preventDefault();
$('#modalContentTest').modal({ position: ["25%", "5%"] });
//row.addClass('highlight');
//$('#tbEdit').val(bID);
});
//Haven't even tried to add the hover stlying part yet; can't get this to work.
}
当我尝试调用 helpGrid();我收到一个未定义的错误...
显然我是 jQuery 新手,但我确实有 jQuery 在行动中,我正在搜索它,现在寻找答案......
请帮忙..
谢谢!!!
【问题讨论】:
-
更正了 asp.net 标签与 asp 和 .net 标签...
-
谢谢...没注意...
标签: asp.net javascript jquery