帮助防止默认 [英] Help with preventdefault

查看:54
本文介绍了帮助防止默认的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个确认对话框,在您单击表单向导上的(#step0Next")后会弹出.当前,在您按下下一步按钮后,它会弹出.我需要它在您单击该步骤(步骤1)上的按钮时弹出,而不是在步骤2时弹出.如何停止按钮的默认操作,直到用户在对话框中单击确定"为止.

I have a confirmation dialogue that pops after you hit ("#step0Next") on a form wizard. Currently it pops after you hit the button on the next step. I need it to pop when you hit the button on THAT step (step 1) not when it goes to step 2. How do I stop the default action of the button until the user click's "OK" in the dialogue?

$("#step0Next").live('click', function(event) {
  event.preventDefault();
  if($("#RT").is(":checked") && !$(".ex").is(':checked')) { 
       return confirm ('foo');
       //alert("You have not selected any exchanges for which to receive real time market data from. If you continue, you will only receive real time data for market metrics and ten minute delayed data for everything else. Do you wish to continue?"); 
       $(this).die('click');
  } 
});

推荐答案

这不起作用.这样做了:

this didn't work. This did:

<script type="text/javascript">
    $("#step0Next").live('click', function(event) {
      $('#step1Prev').click();  //go back to step 1
      if($('#RT').is(':checked') && !$('.ex').is(':checked')) {
          if(!confirm("You have not selected any exchanges for which to receive real time market data from. If you continue, you will only receive real time data for market metrics and ten minute delayed data for everything else. Do you wish to continue?")) return;
          $('#step0Next').die('click');
      }
      $(this).triggerHandler('click');
    });
</script>

这篇关于帮助防止默认的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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