Skip to content

Instantly share code, notes, and snippets.

@morosmo
Forked from dantetesta/Popup Paginação.js
Last active February 20, 2025 18:56
Show Gist options
  • Save morosmo/a26345e0fc5b62fdd06123b011952198 to your computer and use it in GitHub Desktop.
Save morosmo/a26345e0fc5b62fdd06123b011952198 to your computer and use it in GitHub Desktop.
/// PROBLEM ///
// Listing grid of a CPT.
// Each row has an EDIT button.
// The button opens a JetPopup with a form inside.
// After editing the fields, I cannot configure a REDIRECT action in the form, as it refreshes the page and the listing returns to the first page.
// If the edit occurred on page 10, it's a hassle to have to return to the page where you were before EDITING every time.
// 👉 Place inside an HTML widget on the page where the popup will open.
jQuery(document).ready(function ($) {
$(window).on("jet-popup/render-content/ajax/success", function (event, params) {
$(document).on("jet-form-builder/ajax/on-success", function () {
$(window).trigger({
type: "jet-popup-close-trigger",
popupData: {
popupId: params.data.popupId,
constantly: false,
},
});
});
});
});
//Check Form Submission:
document.addEventListener("DOMContentLoaded", function () {
const { addAction } = window.JetPlugins.hooks;
addAction("jet.fb.observe.after", "test/onSubmit", init);
function init(observable) {
console.log("Observable Form Object => : ", observable);
observable.form.submitter.status.watch(onFormSubmit);
}
function onFormSubmit() {
console.log("Submission This Log :", this);
// If the form success
if (this.current === "success") {
console.log("Form submission successful!");
alert("Form successfully submitted!");
} else if (this.current === "invalid_email") {
console.log("Form submission failed!");
alert("Form submission failed! Invail Email issue");
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment