0

我有一个表格 > tr(具有唯一 ID)> td(包含 HTML 格式的数字)> td(包含带有 class=”delete” 的图像 > img 一个 jQuery 脚本以图像为目标并触发请求,更新文件(通过删除 TD 中带有 TR ID 和数字的行)。成功后,通过属性 src 将图像从“ON”更改为“OFF”。

这样可行。没问题。

我的脚本:

$(document).ready(function() {

$(‘table td img.delete’).click(function(){

$.get(“deleteRow.php”, {id: $(this).parent().parent().attr(‘id’)} );
$(this).attr(“src”, “img/code_off.gif”);

});
});

然后,我添加了一个模态窗口(使用 Zebra Dialog)。现在,我的问题是:

当我单击“删除”图像时,它会触发 zebra_dialog。美好的。我可以得到TR的ID。但我绝不可以更新图像 src !:(

我的代码(我必须承认,我对此很陌生,所以它可能是错误的或不正确的写法......):

$(document).ready(function() {

$(‘table td img.delete’).bind(‘click’, function(e) {

var id = $(this).parent().parent().attr(‘id’);

e.preventDefault();
$.Zebra_Dialog(‘my question ?’, {
‘type’: ‘question’,
‘title’: ‘my title’,
‘buttons’: [
{caption: 'YES', callback: function() { /* ??????? THERE SHOULD BE THE EVENT FIRED, therefore the IMG shall be updated, which is not, and I can't get it to work... I've been working around this : $('#'+id+'', 'this').attr("src", "img/code_off.gif") } */ }},
{caption: 'NO', callback: function() { alert('num : '+id+''); /* HERE, WE DO NOTHING, so just checking the ID, which is OK, then modal self-closes. */ }}
]
});
});

});

请问有人有提示或解决方案吗?谢谢 ;)

4

0 回答 0