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

Links in table header #109

Closed
kviktor opened this issue Apr 29, 2014 · 3 comments
Closed

Links in table header #109

kviktor opened this issue Apr 29, 2014 · 3 comments

Comments

@kviktor
Copy link
Contributor

kviktor commented Apr 29, 2014

When I simply click the th element the sorting works fine, but if the th contains a link and I click that it follows the link. I modified the source to this and it seems to work this way, is there a better way to solve this issue?

@@ -18,7 +18,7 @@
       // ==================================================== //

       // Do sorting when THs are clicked
-      $table.on("click.stupidtable", "th", function() {
+      $table.on("click.stupidtable", "th, th a", function() {
         var $this = $(this);
         var th_index = 0;
         var dir = $.fn.stupidtable.dir;
@@ -83,6 +83,7 @@
           // More reliable method of forcing a redraw
           $table.css("display");
         }, 10);
+        return false;
       });
     });
   };
@joequery
Copy link
Owner

I would just make a prevent default somewhere, it doesn't have to be in the plugin source.

$("#mytable th a").on("click", function(){
    // do stuff
    return false
});

@kviktor
Copy link
Contributor Author

kviktor commented Apr 29, 2014

Thank you, it works!

$("#mytable th a").on("click", function(event) {
   event.preventDefault();
});

@joequery
Copy link
Owner

Good to know, thanks for the issue! :)

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