I've got an ajax form submission working well but I'd like to add a "success" class to indicate to the user that the request was completed when the user checked or unchecked a box. I've tried a few things so far:
$(".box").change(function() {
var id=$(this).val();
var dataString = "id=" + id + "&crudtype=myapp";
var clickedObj = $(this).parent().parent();
$.ajax( {
type: "POST",
url: "/myphppage",
data: dataString,
cache: false,
success: function() {
var oldClass = clickedObj.attr("class");
clickedObj.fadeIn(1400, function() {
clickedObj.removeClass(oldClass);
clickedObj.addClass("updated");
});
clickedObj.fadeOut(1400, function() {
clickedObj.removeClass("updated");
clickedObj.addClass(oldClass);
});
}
});
});
That one does indeed apply the "updated" class but the fadeOut actually removes the entire row of data (parent().parent() is the tag that I'm targeting.)
$(".box").change(function() {
var id=$(this).val();
var dataString = "id=" + id + "&crudtype=myapp";
var clickedObj = $(this).parent().parent();
$.ajax( {
type: "POST",
url: "/myphppage",
data: dataString,
cache: false,
success: function() {
var oldClass = clickedObj.attr("class");
clickedObj.removeClass(oldClass);
clickedObj.addClass("updated", 1000);
clickedObj.removeClass("updated", 1000);
clickedObj.addClass("updated");
}
});
});
I also tried this, but all that happens is that it (evidently) removes the existing class, adds the new one, and then does the same thing in reverse immediately so the new class is never seen. It appears that the 1000 delay is ignored despite the fact that I'm running jQueryUI on this site.
Thanks to anyone who can help!
EDIT: Adding in HTML code:
博主遇到一个挑战,即在用户勾选或取消复选框后,通过Ajax提交表单并更新行的状态。问题在于淡入淡出效果导致整个行被移除,而不是仅仅改变类。尝试了两种方法,但都无法成功实现仅添加和移除'updated'类而不影响其他样式。寻求社区的帮助以解决这个问题。
1001

被折叠的 条评论
为什么被折叠?



