-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to remove Click listener #233
Comments
Dears, I found a solution, but adjusting the script "bootstrap5.modal.forms.js" as the following: const modalForm = function(elem, options) {
// Default settings
let defaults = {
modalID: "#modal",
modalContent: ".modal-content",
modalForm: ".modal-content form",
formURL: null,
isDeleteForm: false,
errorClass: "is-invalid",
asyncUpdate: false,
asyncSettings: {
closeOnSubmit: false,
successMessage: null,
dataUrl: null,
dataElementId: null,
dataKey: null,
addModalFormFunction: null
}
};
let settings = {...defaults, ...options}
- elem.addEventListener('click', () => {
- modalFormCallback(settings);
- })
+ elem.clickHandler = () => {
+ modalFormCallback(settings);
+ };
+ elem.addEventListener('click', elem.clickHandler)
return elem;
} this way I can retrieve the current click handler in the button from my script and remove it before adding a new one. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello guys,
First of all thanks for the great extension, I'm probably having problem maybe for not using the extention in the most optimal way, but I'm having a hard time trying to figure out a solution.
I have a table in a list view that user can select items in checkbox and eveytime user toggles a checkbox, there's a javascript that assigns the modalForm with an uptaded form_url, see below:
So the problem here is that everytime I call the "modalForm" function it adds a new event handler to my deleteTransactions button, the problem is, I can't remove this listener without having the original handler that was used by this.
So, is there any way I'm not seeing to remove the modalForm click handler?
As I'm kind new to Django itself, there's a better way to achieve this behavior?
Thanks!
Rafael
The text was updated successfully, but these errors were encountered: