setting target _blank for just one form submit action

前端 未结 3 1340
刺人心
刺人心 2021-01-11 18:22

I\'m submitting a form to my rails app, with two submit buttons. They both go to the same controller action, and use the same form, but on one submit action i want to make

3条回答
  •  温柔的废话
    2021-01-11 19:01

    In order to handle all submit cases (not just clicks) I would do something like the following:

    $("form").submit(function(e) {
      if($(e.srcElement).is(".popup")){
        $(this).attr("target", "_blank");
      }
    });
    

提交回复
热议问题