-
-
Notifications
You must be signed in to change notification settings - Fork 57
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
Problem to ignore a click with onClick button link #110
Comments
This question is similar to Jquery dirtyforms not working properly on DIV click and window.location.href. Using |
Thanks I will check that. |
onClickActually, no onclick is not "popular". Modern unobtrusive code uses event handlers that are attached from outside of the HTML (which can be overridden by jQuery). For example: $('#add_city').click(function (event) {
location.href = 'someurl';
}); It is recommended to not use the window.location and window.location.hrefBut that is beside the point because the issue here is that you are using I believe a fix for this is a feature we should have. However, I have checked and it seems that there is no way to override the So the only real choice here is to add a method to Dirty Forms to call instead of $.DirtyForms.location = 'someurl';
// or perhaps
$.DirtyForms.location.href = 'someurl'; It is possible to override the var _window = {
set location (url) {
alert(url);
window.location = url;
}
};
(function (window) {
// In this context, the window object is acutally calling _window
// so you will get an alert before navigating to the URL.
$('#test-nav').click(function () {
window.location = 'someurl';
});
}(_window)); Unfortunately, it doesn't seem like there is a simple way to clone the whole So, I am upgrading this to a feature request. We need at minimum to implement something like Hopefully, some JavaScript guru can provide a more reasonable solution to put into the documentation as a drop-in replacement for References: |
Thanks a lot, I will check future releases. For now, I'm using another dirty script, which I have customized. |
Not sure if this helps or not... $('#add_city').click(function (event) { event.preventDefault(); location.href = 'someurl'; }) |
Hi,
I want to ignore click of a specific button
<button id="add_city" class="btn btn-success btn-sm dirtyignore " type="button" onClick="location.href='someurl'" > ADD City</button>
I also have button links that look like this
onclick="contacts.editContact(this,<?php echo $contact['contact_id']; ?>)
I have read a lot of similar issues and I have tried some of suggestion to fix it with no luck.
When the form is dirty and I click on this button it is giving an alert and not ignoring this button click...
I'm testing using Chrome
Thanks
The text was updated successfully, but these errors were encountered: