首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在jquery-easyui中禁用多次单击保存按钮

在jquery-easyui中禁用多次单击保存按钮
EN

Stack Overflow用户
提问于 2017-07-24 14:03:43
回答 1查看 235关注 0票数 1

在easyui中,在创建新用户时,如何在将请求发送到php以在数据库中插入相同内容时禁用对保存按钮的多次单击

代码语言:javascript
复制
function saveUser() {

  $('#fm').form('submit', {
    url: url,

    onSubmit: function() {
      return $(this).form('validate');
    },

    success: function(result) {

      if (result === 'exists') {
        $.messager.alert('Alert', 'Name already exists!\nPlease enter different Name', 'info');
        $('#fm').form('clear');
      } else {
        $('#dlg').dialog('close'); // close the dialog
        $('#dg').datagrid('reload'); // reload the user data
      }
    }
  });
}

在没有收到来自php文件的响应之前,我不希望发送另一个请求。

EN

回答 1

Stack Overflow用户

发布于 2017-07-24 14:33:19

您可以在单击提交按钮后立即将其禁用,

请检查以下代码,希望能对您有所帮助:

代码语言:javascript
复制
function saveUser() {

  $('#fm').form('submit', {

    url: url,

    onSubmit: function() {
       //Code to Disable the submit button comes here.
       $("#SubmitButton").attr('disabled',true);//Assuming SubmitButton is the ID of the button.
      return $(this).form('validate');
    },

    success: function(result) {

      if (result === 'exists') {
        $.messager.alert('Alert', 'Name already exists!\nPlease enter different Name', 'info');
        $('#fm').form('clear');
      } else {
        //If you want to allow the user to click on the Submit button now you can enable here like this :
        $("#SubmitButton").attr('disabled',false);
        $('#dlg').dialog('close'); // close the dialog
        $('#dg').datagrid('reload'); // reload the user data
      }
    }
  });
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45273611

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档