Last active
February 20, 2025 19:19
-
-
Save morosmo/fef9b3fc5bd3a12ce780ef6a0b12a760 to your computer and use it in GitHub Desktop.
Refresh Lisitng Grid on Form Submit - Crocoblock Elementor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This script listens for a successful form submission event from JetFormBuilder. | |
// When the form is successfully submitted, it waits for 2 seconds, logs a message, | |
// closes the popup, and refreshes the listing grids on the page. | |
jQuery(document).ready(function ($) { | |
$(document).on("jet-form-builder/ajax/on-success", function () { | |
setTimeout(function () { | |
console.log("Form Submitted Successfully"); | |
$(".jet-popup__close-button").trigger("click"); | |
refreshListingGrids(); | |
}, 2000); | |
}); | |
// Function to refresh all listing grids on the page | |
function refreshListingGrids() { | |
const $grids = $(".topiclisttingcontianer"); | |
if ($grids.length) { | |
console.log('Reloading listing grids...'); | |
$grids.each(function () { | |
reloadListingGrid($(this)); | |
}); | |
} else { | |
console.log('No listing grids found to reload.'); | |
} | |
} | |
// Function to reload a single listing grid | |
function reloadListingGrid($widget) { | |
const navData = $widget.find(".jet-listing-grid__items").data("nav"); | |
if (!navData) { | |
return; | |
} | |
const args = { | |
handler: "get_listing", | |
container: $widget.find(".elementor-widget-container"), | |
masonry: false, | |
slider: false, | |
append: false, | |
query: navData.query, | |
widgetSettings: navData.widget_settings, | |
}; | |
window.JetEngine.ajaxGetListing(args, function (response) { | |
const $container = $widget.children(".elementor-widget-container"); | |
const $result = $(response.data.html); | |
$container.html($result); | |
window.JetEngine.widgetListingGrid($widget); | |
window.JetEngine.initElementsHandlers($container); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment