通过ajax刷新数据时覆盖表单“重置”行为 [英] Override the form 'Reset' behavior when data is refreshed via ajax

查看:216
本文介绍了通过ajax刷新数据时覆盖表单“重置”行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我依靠表单的重置行为取消编辑,我面临的问题是,一旦发布数据通过ajax更新,重置仍然会恢复为页面加载的数据origionally。

I am relying on the "Reset" behavior of a form to cancel the edits, the problem i am facing is that once post the data is updated via ajax, the reset still reverts back to the data that was loaded with the page origionally.

所以基本上我需要做的是重置重置功能。有意义吗?

So basically what I need to be able to do is "Reset" the "Reset" function. Make sense?

推荐答案

试试这个:

$("#yourForm").bind("reset", function() {

    // reset the form manually with the "newest" data

    return false;
});

在这种情况下,您必须存储新数据(您从Ajax回调中获得的数据) 。然后,当用户重置表单时,您手动使用该数据填充表单元素。

In this case, you will have to store the new data (that you got from the Ajax callback). And then, when the user resets the form, you manually fill the form elements with that data.

这篇关于通过ajax刷新数据时覆盖表单“重置”行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆