CMS Development

Jlawal
Stratege/Strategin

Javascript "NaN" statistics

lösung

Hi all 🙂

 

I'm working on this page. There is a blue banner above the 'Other opportunities' section that displays stats. In the page editor the stats display correctly (please see image below). I have updated this page a number of times but the first three stats don't display, showing "NaN" instead.

 

Page editor viewPage editor view

 

Any advise on this would be greatly appreciated.

 

Many thanks,

Jamila

0 Upvotes
1 Akzeptierte Lösung
Kevin-C
Lösung
Trendsetter/-in | Partner
Trendsetter/-in | Partner

Javascript "NaN" statistics

lösung

@JlawalGreat to hear!

 

You can updae the number using jQuery.

With that said there are a hundreds of jQuery solutions.

 

Here are some ideas to look into.

1) Updating the script that modifies the DOM element(displayed number) itself. Rather than "printing" the number it could print a string thst would include the commas. This would probably best replicate the animation you have currently.

 

2) Update the DOM element aftert the animation.

Kevin Cornett - Sr. Solutions Architect @ BridgeRev

Lösung in ursprünglichem Beitrag anzeigen

4 Antworten
Kevin-C
Trendsetter/-in | Partner
Trendsetter/-in | Partner

Javascript "NaN" statistics

lösung

Hey @Jlawal Interesting issue here!

 

NaN for the non-js user means "not a number".

So Somewhere between the editor and something is interfearing with the script.

 

Now this is just a guess, but if you enter the final numbers 20,012 or 75,085,670 into the editor without the commas does that change anything?

My thought here is that maybe there is an error when parsing the author input.

Kevin Cornett - Sr. Solutions Architect @ BridgeRev
Jlawal
Stratege/Strategin

Javascript "NaN" statistics

lösung

Hi @Kevin-C , thank you for your help!

 

I've removed the commas and the nan has disappeared. You were right! Do you know if there is anyway to add the commas back in in a way that doesn't affect anything? It looks a bit odd without the commas Smiley (überglücklich)

0 Upvotes
Kevin-C
Lösung
Trendsetter/-in | Partner
Trendsetter/-in | Partner

Javascript "NaN" statistics

lösung

@JlawalGreat to hear!

 

You can updae the number using jQuery.

With that said there are a hundreds of jQuery solutions.

 

Here are some ideas to look into.

1) Updating the script that modifies the DOM element(displayed number) itself. Rather than "printing" the number it could print a string thst would include the commas. This would probably best replicate the animation you have currently.

 

2) Update the DOM element aftert the animation.

Kevin Cornett - Sr. Solutions Architect @ BridgeRev
Jlawal
Stratege/Strategin

Javascript "NaN" statistics

lösung

Thank you for your help with this @Kevin-C . That has worked perfectly! Katze (überglücklich)