0

I'm trying to disable click events on 'disabled' pagination buttons in Datatables.

I've been trying to do so like with this code

$('.dataTables_paginate span.ui-state-disabled').click(function(){return false;});

But that only works on the worded navigation (i.e., Next, Previous, First, Last) and not the numbering. I've tried targeting it a dozen different ways, to no avail. Is there something in the datatables API that I'm missing, or does anyone out there have another idea how to disable this? The disable class is applied dynamically through datatables.

If you have a minute, please help -- this is driving me crazy!

1
  • they should be disabled by default and unclickable unless there's another page it can navigate to.. Can you make an example on jsfiddle.net? Commented Sep 28, 2012 at 14:58

3 Answers 3

3

Too late to participate but for the others I solve this issue using CSS only

a.paginate_button.current {
    pointer-events: none;
}

Hope it helps

Sign up to request clarification or add additional context in comments.

Comments

0

The problem is that the datatable api probably have a click listener for paginations buttons and they will be executed before yours scripts.

BUT: if your intention is to stop the default event of the click, try that:

$('.dataTables_paginate span.ui-state-disabled').click(function(e){
     e.preventDefault();
});

2 Comments

Is there a way to override these? preventDefault(), stopPropagation() and the like don't seem to work.
If you have access to the datatable scripts you can change the default behavior.
0

Try adding e.preventDefault(); to your click function.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.