Skip to content
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

Issue with DataTables for empty anchor links #54

Closed
furiabhavesh opened this issue Aug 1, 2013 · 6 comments
Closed

Issue with DataTables for empty anchor links #54

furiabhavesh opened this issue Aug 1, 2013 · 6 comments

Comments

@furiabhavesh
Copy link

I have a page which consists of User list on left side and its details appearing on right side on click of username. The details section is a form(being checked for dirty) which admin can change.

The problem is, on left hand side I have userlist in a DataTables with pagination feature. So now if I am adding values for new user which makes the form dirty and click on DataTables's pagination links (Next or Previous) before saving the user record, the dirtyForm warning is shown properly. If I click on "Continue" the page redirects to "/undefined". I found this thing when I enabled the dirtyLog.

According to me, its happening because the prev-next buttons in datatables are anchor tags without any "href" attribute whose value is being used by dirtyForms before showing the "Continue" - "Stop" popup.

I have fixed this thing for now by just checking for undefined value by replacing below line in jquery.dirtyforms.js file

location.href = anchor.attr('href');

with

if (anchor.attr('href')!=undefined) {
  location.href = anchor.attr('href');
}
@furiabhavesh
Copy link
Author

Like above situation, I have so many anchor links for various purpose with no "href" values.

Eg: - I have a requirement where I dont want to show dirtyForm warning if user presses "Cancel" link on form.

I am ignoring dirtyForms popup on click of cancel link as follows.

function skip_dirty_form_check_on_cancel(){
  $(".dirtyCancel").click(function(){
    $("form.jq-validate").removeClass("dirty");
  });
}

Is there any better way to achieve above thing because I have more than 1 element for which I want to ignore dirtyForm warning and I dont want my above code to look like below

$(".dirtyCancel, #el1, #el2, #el3_and_so_on").click(function(){
........
});

@snikch
Copy link
Owner

snikch commented Aug 1, 2013

If you can create a pull request for the fix with links with no href, that would be great. As for the cancel links etc. if you add the class ignoreDirty (you can modify that in the settings), then those links should be ignored.

@furiabhavesh
Copy link
Author

Pull request created here

@furiabhavesh
Copy link
Author

@snikch : Is there any issue in the pull request ? Its been long time now

@snikch
Copy link
Owner

snikch commented Feb 19, 2014

Sorry @furiabhavesh, that's completely my laziness. Thanks for reminding me – I've merged the pull request! :shipit:

@furiabhavesh
Copy link
Author

Thanks @snikch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants