【问题标题】:Disable LI being clicked if form has not been submitted如果表单尚未提交,则禁用 LI 被单击
【发布时间】:2012-02-23 17:48:43
【问题描述】:

如果尚未提交表单,我需要禁用 LI 菜单项。如果用户尝试单击 li,我希望显示警报甚至提示来告诉用户或为用户提供以下选项

alert("We are sorry as this is a new business lead, you need to save the information first.");

或

promt("we understand that you want to continue, please click ok for us to save the information you have inputted");

【问题讨论】:

    标签: jquery menu alert prompt


    【解决方案1】:

    方法很多,试试吧:

    $.ajax({
       ...
       beforeSend: function() {
           if (isMyFormSubmitted()) {
               $('li').click(function() {
                   alert('...');
               });
           } else {
               $('li').click(function() {
                   prompt('...');
               });    
           }
       }
    });
    

    isMyFormSubmitted() 是一些函数,它根据表单是否已提交而返回真或假。显然,您必须遍历所有字段以查看该函数中是否有任何更改。

    【讨论】:

      猜你喜欢
      • 2021-02-22
      • 1970-01-01
      • 2023-04-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-19
      • 2020-04-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多