How to use the @rails/ujs.fire function in @rails/ujs

To help you get started, we’ve selected a few @rails/ujs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github decidim / decidim / decidim-core / app / packs / src / decidim / confirm.js View on Github external
dialog.confirm(message).then((answer) => {
    const completed = Rails.fire(element, "confirm:complete", [answer]);
    if (answer && completed) {
      // Allow the event to propagate normally and re-dispatch it without
      // the confirm data attribute which the Rails internal method is
      // checking.
      $(element).data("confirm", null);
      $(element).removeAttr("data-confirm");

      // The submit button click events won't do anything if they are
      // dispatched as is. In these cases, just submit the underlying form.
      if (ev.type === "click" &&
        (
          $(element).is('button[type="submit"]') ||
          $(element).is('input[type="submit"]')
        )
      ) {
        $(element).parents("form").submit();
github danbooru / danbooru / app / javascript / src / javascripts / favorite_groups.js View on Github external
FavoriteGroup.open_favgroup_dialog = function(e) {
  if ($(".add-to-favgroup").length === 1) {
    // If the user only has one favorite group we don't need to ask which group to add the post to.
    let favgroup = $(".add-to-favgroup").get(0);
    Rails.fire(favgroup, "click");
  } else {
    $("#add-to-favgroup-dialog").dialog("open");
  }
  e.preventDefault();
}
github decidim / decidim / decidim-core / app / packs / src / decidim / confirm.js View on Github external
const allowAction = (ev, element) => {
  const message = $(element).data("confirm");
  if (!message) {
    return true;
  }

  if (!Rails.fire(element, "confirm")) {
    return false;
  }

  if (TEMPLATE_HTML === null) {
    TEMPLATE_HTML = $("#confirm-modal")[0].outerHTML;
    $("#confirm-modal").remove();
  }

  const dialog = new ConfirmDialog(
    $(element)
  );
  dialog.confirm(message).then((answer) => {
    const completed = Rails.fire(element, "confirm:complete", [answer]);
    if (answer && completed) {
      // Allow the event to propagate normally and re-dispatch it without
      // the confirm data attribute which the Rails internal method is
github pay-rails / pay / test / dummy / app / javascript / controllers / braintree_controller.js View on Github external
paymentMethod(error, payload) {
    if (error) {
      console.error("Error with payment method:", error)
      return
    }

    this.addHiddenField("processor", "braintree")
    this.addHiddenField("card_token", payload.nonce)

    Rails.fire(this.formTarget, "submit")
  }
github danbooru / danbooru / app / javascript / src / javascripts / artist_commentaries.js View on Github external
"Submit": function() {
        let form = $("#add-commentary-dialog #edit-commentary").get(0);
        Rails.fire(form, "submit");
        $(this).dialog("close");
      },
      "Cancel": function() {
github danbooru / danbooru / app / javascript / src / javascripts / utility.js View on Github external
"Submit": function() {
        let form = $dialog.find("form").get(0);
        Rails.fire(form, "submit");
      },
      "Cancel": function() {