【发布时间】:2011-01-01 05:13:38
【问题描述】:
我在重新检查某些复选框后遇到问题 ajax 调用会更新一个表。
我有一个项目称为“共享”的表格。
我想:
1) 检查任何已检查的共享并将其保存到数组
2) 执行我的 ajax 调用来更新共享表
3) 重新检查我们在 ajax 更新之前检查的所有内容。
我的代码不起作用,我不明白为什么?
非常感谢任何提示、帮助或建议。
// Array to hold our checked share ids
var savedShareIDs = new Array();
// Add checked share ids into array
$("input:checkbox[name=share_ids]:checked").each(function() {
savedShareIDs.push($(this).val());
});
// Do ajax update
Dajaxice.pagination_shares('Dajax.process',{'id':1, 'page':1})
// Re-check any that were checked before ajax update
$("input:checkbox[name=share_ids]").each(function()
{
if ( $.inArray( $(this).val(), savedShareIDs) > -1 ) {
$(this).attr('checked',true)
}
});
问题是复选框没有检查。
我很确定循环正常工作并且 inArray 检查工作正常。
只是不检查复选框。 谁能看出我哪里出错了?
谢谢。
【问题讨论】:
标签: jquery ajax arrays push checkbox