[ACCEPTED]-Disabled link in Bootstrap Pagination-anchor

Accepted answer
Score: 30

In the docs, those buttons are just disabled 5 manually. It has nothing to do with the 4 .pagination styling.

You could use that

$('.pagination .disabled a, .pagination .active a').on('click', function(e) {
    e.preventDefault();
});

Note: If you 3 use an ajax based pagination you have to 2 put this piece of code in the update handler 1 or use delegated events instead

Score: 6

If you write the html dynamically server 2 side (with django for example) and you don't 1 want to use javascript you could do this:

pseudo code:
if (Model.HasNext()) {
   <li> // normal link
      <a href="www.someurl.com/page=i">next</a>
   </li>
} else {
   <li class="disabled"> // disabled link
      <a href="javascript: void(0)">next</a>
  </li>
}
Score: 6

As a reference, here is what Bootstrap does:

&.disabled,
&[disabled] {
  cursor: not-allowed;
  pointer-events: none; // Future-proof disabling of clicks
  .opacity(.65);
  .box-shadow(none);
}

0

Score: 3
$('.disabled a').click(function(){
    return false;
});

0

More Related questions