Home>

Currently, id and onclick are written for button as follows.
In this case, two events in the script are called, but if the return value of the onclick event is determined with priority, and it is false
$(document) .on ("click", ".xxx_btn", function ()
Is it possible not to call it?

$(document) .on ("click", ".xxx_btn", function ()
Is basically called in various places, and only certain buttons are controlled by onclick events, and we don't want to call on ("click".

I would appreciate it if you could teach me that the site can be helpful.
Thank you.

<% = f.submit 'Send', id: 'xxx_btn', onclick: "return send_yyy ()"%>
<script>
$(document) .on ("click", ".xxx_btn", function () {
// Various processing
});
function send_yyy () {
// Various processing
  if (condition) {
      return true;
    } else {
      return false;
    }
]
</script>
  • Answer # 1

    Is the one that came up with improvisation like running send_yyy onclick and executing if if is true?

    $(document) .on ("click", "input", function () {
      if (aiueo () === true) {
        alert ('aiueo');
      }
    });
    function aiueo (ok) {
      if (0 === 0) {
        return true;
      } else {
        return false;
      }
    }