Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save iamrealfarhanbd/f0d72b913f3d635503271352bf89b5d4 to your computer and use it in GitHub Desktop.
Save iamrealfarhanbd/f0d72b913f3d635503271352bf89b5d4 to your computer and use it in GitHub Desktop.
This Gist provides a workaround for issues with the "Reset All" button in Ninja Tables when using multiple select options. This code ensures that the "Reset All" button properly interacts with the filter controls, even when they are dynamically generated or modified.
$(document).ready(function() {
console.log("Document is ready");
// Use event delegation to handle clicks on dynamically generated .reset-all elements
$(document).on('click', '.reset-all', function() {
console.log("Reset all button clicked");
if ($('.optWrapper').hasClass('isFloating')) {
// Check if the .fooicon element has the class .fooicon-remove
if ($('.fooicon').hasClass('fooicon-remove')) {
console.log("Class fooicon-remove found");
// Trigger a click event on the .fooicon-remove element
$('.fooicon.fooicon-remove').click();
console.log("fooicon-remove button clicked");
} else {
console.log("fooicon-remove class not found");
}
};
});
// Optional: You might want to handle the click event for the select box if needed
$(document).on('click', '.optWrapper', function() {
console.log("Select box clicked");
// Additional logic if needed
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment