IE Specific Pagination bug (Description and Fix included)

IE Specific Pagination bug (Description and Fix included)

offsoundoffsound Posts: 2Questions: 0Answers: 0
edited March 2012 in Bug reports
Hello,

I was answering a question on stackoverflow, and ran into a dataTables bug that I thought you guys should know about.

Here's the question that describes the problem: http://stackoverflow.com/questions/9629296/jquery-datatable-pagination-issue-in-ie9

I narrowed it down to this function, which is around line 4613 of http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.0/jquery.dataTables.js :

[code]
function _fnBindAction( n, oData, fn )
{
$(n)
.bind( 'click.DT', oData, function (e) {
fn(e);
n.blur(); // Remove focus outline for mouse users
})
.bind( 'keypress.DT', oData, function (e){
if ( e.which === 13 ) {
fn(e);
}})
.bind( 'selectstart.DT', function () {
/* Take the brutal approach to cancelling text selection */
return false;
});
}
[/code]

In IE9 (didn't test against earlier versions), it's having trouble with what appears to be the scoping of the `n` variable. When you click on a page number in the pagination bar, you get the following error message:

[code]
Line: 4613
Error: Unexpected call to method or property access.
[/code]

However, It works fine (or is ignored) in other browsers. I was able to fix this issue by changing n.blur(); to $(n).blur() on line 4613.

There might be a better solution, but this seems to fix it for me -- and it still works in the other browsers.

Thanks,
Josh

Replies

  • allanallan Posts: 63,383Questions: 1Answers: 10,449 Site admin
    Thanks for that - however I'm not able to reproduce the problem myself. For example: http://datatables.net/release-datatables/examples/basic_init/zero_config.html - seems to run absolutely fine in IE9 for me when clicking to sort.

    Can you link me to a test page which does show the issue? Your fix looks absolutely fine, but I'd just like to check that there isn't something "deeper" going on.

    Thanks,
    Allan
  • offsoundoffsound Posts: 2Questions: 0Answers: 0
    I believe the problem happens when you set:

    [code]
    "sPaginationType": "full_numbers"
    [/code]

    And then you click on any of the pagination numbers on the bottom right.

    It doesn't seem to have any adverse effects, but if you look at the developer console (f12 in IE) you get that error, every time you click on a page number.

    jsfiddle has been down, so I had to use this site: http://plunker.no.de/he7GGr/

    You can run the above link and see the error in IE, but the plunker editor doesn't seem to like IE, so open this next link in a real browser: http://plunker.no.de/edit/he7GGr if you want to see the source.

    By the way, thanks for creating/maintaining dataTables. It's been one of the most useful plugins I've worked with in jQuery.

    - Josh
  • allanallan Posts: 63,383Questions: 1Answers: 10,449 Site admin
    Ah thanks - got it now. This is actually a known issue with 1.9.0 - it was in fact the first fix that when in after 1.9.0 was released :-). I'll be wrapping up 1.9.1 soon, but until then you can get the fix in the nightly: http://datatables.net/download .

    > By the way, thanks for creating/maintaining dataTables. It's been one of the most useful plugins I've worked with in jQuery.

    Thanks very much! :-)

    Allan
  • alexxualexxu Posts: 1Questions: 0Answers: 0
    edited April 2012
    This is really a bug i met. THX.
  • mwhousermwhouser Posts: 14Questions: 1Answers: 0
    Went to upgrade 1.8.2 to 1.9.0 for resizable tables and rammed into this bug inside 20 seconds.

    Eagerly waiting for 1.9.1 with the fix.
  • allanallan Posts: 63,383Questions: 1Answers: 10,449 Site admin
    The nightly with this fix is available on the downloads page, or you can hang on for the 1.9.1 release which I fully plan to release this week.

    Regards,
    Allan
This discussion has been closed.