Rails :confirm modifier callback?

前端 未结 3 473
遥遥无期
遥遥无期 2021-02-08 01:54

I want to call a javascript function that will be conditional upon a user\'s response to the confirm box.

For example, I have the following anchor:

<%         


        
3条回答
  •  野性不改
    2021-02-08 02:20

    In 2020, the accepted answer didn't work for me. I ended up doing something like this instead:

    $(document).on('confirm:complete', function (e) {
      if (e.originalEvent.detail[0]) {
        // user confirmed!
        myCallbackFunction();
      } else {
        // user canceled!
      }
    });
    

提交回复
热议问题