0

我有一个小的 jquery 脚本,当我单击网格/表(从 webgrid 构建)中的 ajax actionlink 时,它将用旋转的轮子替换内容。它只在第一次工作。

$('#thisGrid tr td').click(function () {
    $(this).html('<img  src="@Url.Content("~/Content/ajax-loader.gif")" alt="Loading... Please Wait" style="height: 20px;"/>');
});

我还没有发现任何东西可以让我确定为什么会这样......关于为什么会发生这种情况的任何想法?

4

2 回答 2

1

可能尝试使用实时点击功能。

$('#thisGrid tr td').live('click', function(){ ...
于 2012-11-07T16:12:46.603 回答
0

委托活动

$('#thisGrid').on('click','td' , function () {
    $(this).html('<img  src="@Url.Content("~/Content/ajax-loader.gif")"
                alt="Loading... Please Wait" style="height: 20px;"/>');
});

更新 jQuery 1.6 及以下

 $('#thisGrid').delegate('td' , 'click', function () {
        $(this).html('<img  src="@Url.Content("~/Content/ajax-loader.gif")"
                    alt="Loading... Please Wait" style="height: 20px;"/>');
    });
于 2012-11-07T16:13:22.913 回答