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

Uncaught TypeError: Cannot read property 'toString' of undefined at Object.sortNatural #1566

Closed
own3mall opened this issue Jul 10, 2018 · 5 comments
Labels

Comments

@own3mall
Copy link

I'm receiving the below error on the latest version of tablesorter (along with my older version of v2.29.5):

Uncaught TypeError: Cannot read property 'toString' of undefined
at Object.sortNatural (jquery.tablesorter.min.js:formatted:1319)
at Object.sortNaturalAsc (jquery.tablesorter.min.js:formatted:1364)
at jquery.tablesorter.min.js:formatted:1235
at Array.sort (native)
at Object.multisort (jquery.tablesorter.min.js:formatted:1209)
at jquery.tablesorter.min.js:formatted:1183

It seems to not like the column data which consists of the following:

<td class="centerAlign userGlimpse"><img src="https://serv1.dragndropz.com/user_images/2018_07_09/thumbs/397_cXSCjb_chronic_I_miss_u.jpg" alt="rawr57"><br><span class="linkActor underline visitUser">rawr57</span></td>

Attached is a screenshot showing the problem:

Attached Image Hosted by DragNDropz www.dragndropz.com

Any idea why this might be happening?

@Mottie
Copy link
Owner

Mottie commented Jul 10, 2018

Hi @own3mall!

What parser is being set for that column? Would you please share the tablesorter initialization code being used.

@own3mall
Copy link
Author

I didn't set one. Just using the default.

function styleAndMakeTablesSortable(){
	$(".sortableTable").tablesorter({
		theme : 'blue'
	}); 
	
	// Rehighlight on sort
	$(".sortableTable").bind("sortEnd", function() {
		styleTableAlternatingRowColors();
	});
	
	// Trigger change since the table contents have probably changed
	// Documentation https://github.com/Mottie/tablesorter/issues/1131
	$(".sortableTable").trigger('update');
	
	styleTableAlternatingRowColors();
}

@Mottie
Copy link
Owner

Mottie commented Jul 10, 2018

I still can't duplicate the issue. By default, the "image" parser is set and extracts the alt attribute from the image. If there is no alt attribute, then it falls back to the text within the cell.

Is there any other script that might be interfering?

Also, you don't need to use trigger('update') immediately after initializing tablesorter.

No matter the cause, I'll modify that bit of code in the core to ensure that the parameters are not undefined.

@Mottie Mottie added the Bug label Jul 10, 2018
@Mottie Mottie closed this as completed in f061f10 Jul 10, 2018
@own3mall
Copy link
Author

own3mall commented Jul 10, 2018

I'm not sure why it was happening either. I'll try to put together a JSFiddle. Pretty sure nothing else was interfering with the script. It was just crashing for some reason.

Thanks for adding a null check though.

@own3mall
Copy link
Author

own3mall commented Jul 10, 2018

Figured it out. The HTML was bad. My closing </tr> tags were actually <tr> opening tags (missing the closing slash).

Now that I've fixed that, I no longer have the issue. Sorry about that... minor syntax errors can drive a person crazy.

However, I still think it's a good idea to have those checks you put in even though it was totally my fault. Thanks for working on this. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants