Last active
February 22, 2025 13:02
-
-
Save Mohsin-Shakeel/bfac2611e95dd01863528b28042c1da8 to your computer and use it in GitHub Desktop.
Update Listing grod widget on form submit - Jetengine 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
jQuery(document).ready(function ($) { | |
$(document).on("jet-form-builder/ajax/on-success", function (event, response, form) { | |
console.log(event, response, form); | |
let submitForm = form[0]; | |
refreshListingGrids(); | |
setTimeout(function () { | |
submitForm.querySelector(".jet-form-builder-messages-wrap > div").remove(); | |
}, 500); | |
}); | |
function refreshListingGrids() { | |
const $grids = $(".topiclisttingcontianer"); //this is the class of the listing grid widget added in advanced tab | |
if ($grids.length) { | |
console.log("Reloading listing grids..."); | |
$grids.each(function () { | |
reloadListingGrid($(this)); //this refference to current lisiting item | |
}); | |
} else { | |
console.log("No listing grids found to reload."); | |
} | |
} | |
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