Uncaught TypeError: Object [object Object] has no method 'charCodeAt'
Uncaught TypeError: Object [object Object] has no method 'charCodeAt'
steveoc
Posts: 9Questions: 0Answers: 0
Hi Allan,
Since the update to 1.9.3 I am receiving the following error:
Uncaught TypeError: Object [object Object] has no method 'charCodeAt' on line 3841.
I have uploaded debug info. code: ekazek
Many thanks
Steve
Since the update to 1.9.3 I am receiving the following error:
Uncaught TypeError: Object [object Object] has no method 'charCodeAt' on line 3841.
I have uploaded debug info. code: ekazek
Many thanks
Steve
This discussion has been closed.
Replies
Thanks,
Allan
I think it is because of the new jquery release
Change the http link to latest jquery version to the 1.7.2 (download it to your local machine)
Regards
If someone is able to give me a test case which shows this problem, so I can reproduce it and debug it, I'll get a fix in forthwith.
Thanks,
Allan
Library jquery.dataTAble.js, in _fnStringToCss(s) function, the line var c = s.charCodeAt(s.length - 1);
I debugged it with alerts and s is an object, not a string
Regards
Excellent. moved back to JQ1.7.2. and Hey Presto.
Strange though - it was working!!
many thanks
Steve
Thanks very much for the log-in - I appreciate that. Its always really helpful to see the code in action!
Have you moved your site back to jQuery 1.7.2 as I'm not seeing the error at the moment. However, I am seeing a warning about an undefined parameter - I think you probably just need to add `"sDefaultContent": ""` to your final column (which is currently mDataProp null and DataTables won't be finding anything for the column).
Thanks again,
Allan
yes I did roll back to 1.7.2.
I've added the sDefaultContent:"" and the warning has disappeared. Many thanks for that.
Though I'm still stumped as to why these errors were now starting to occur as everything was working beautifully!
I'll be pushing a new version of the site (with 1.7.2) in the next 24 hours.
Once I've done this I'll move the current site to a test server with jQuery 1.8 and will let you know so you can have a look at the original error.
Many thanks for your help.
DataTables Rocks!
Steve
Good to hear that helped :-). I look forward (in a funny developer way...) to seeing the error!
Thanks,
Allan
If anyone can give me a link to a page that shows the issue, I'd be really grateful so I fix it.
Allan
The problem is with jQuery UI. The solution seems to be to download jQuery UI 1.8.22.
Allan
Steve
My datatable has option, "sScrollX": "100%",
After remove this option, this error is gone, and table is rendered successfully.
Post a link please.
[code]if ( typeof s == "object" ) return s;[/code]
s contained the whole table object.
Allan
occurs when initialising data table, and passing to it (as data) an empty array.
setting "sDefaultContent" property for columns don't take an effect.
"typeof s... " - takes no effect
unfortunatly i have no time to debug it now (hope to do it later, or just to try to do it =)) ),
my spike is just to make it (that "s") a string (before line 3878)
[code]s = s.toString();[/code]
Allan
in this case: s === false (line 3862) (for me, using Chrome 25)
from line 3862:
[code]
// generating width for invisible column
function _fnStringToCss( s ) {
// "s" is actually "false"
if ( s === null ) { // false !== null
return "0px";
}
if ( typeof s == 'number' ) { // "boolean" != 'number'
if ( s < 0 ) {
return "0px";
}
return s+"px";
}
/* Check if the last character is not 0-9 */
var c = s.charCodeAt( s.length-1 ); //throw an exception
if (c < 0x30 || c > 0x39)
{
return s;
}
return s+"px";
}
[/code]
probably a better solution (depending on posts in this topic) is something like that:
[code]
function _fnStringToCss( s ) {
// if s is a number
if (typeof s == 'number') {
if (s < 0) {
return "0px";
}
return s+"px";
}
// if s is a string
if (typeof s == 'string') {
/* Check if the last character is not 0-9 */
var c = s.charCodeAt(s.length - 1);
if (c < 0x30 || c > 0x39) {
return s;
}
return s + "px";
}
// on any other type - return zero width
return "0px";
}
[/code]
As I said, I need a test case so this can be reproduced and fixed properly, but without a way to reproduce the error I can't do that.
Please also check you are using an update to date version of jQuery UI (again without a test case I'm guessing...).
Allan
My page happened to be using Chrome 26.0.1410.64 jQuery 1.9.1 jQueryUI 1.8.21
Thanks Vic_VI
I'd suggest updating to at least the latest 1.8 of jQuery UI.
I really would like a test page showing this problem, so I can fix this in DataTables core. If someone, anyone!, is experiencing this problem, please link me to the page.
Allan
I had the same problem with datatables 1.9.4 after upgrading jquery 1.7.1 to 1.10.2.
Sometimes the method outerWidth() in _fnScollDraw() returns not a value, but an object (the table object itself).
var iOuterWidth = $(o.nTable).outerWidth();
nScrollHeadTable.style.width = _fnStringToCss( iOuterWidth );
The error than occures in _fnStringCss, because it expects a string.
I found a bug ticket in jquery http://bugs.jquery.com/ticket/12491 which says that it is caused by a hooking outerWidth function in jquery UI.
After upgrading jquery UI from 1.8.17 to 1.10.1 the error has been gone.
Maybe that helps somebody.
Malte