Bootstrap counter with dmx-bind

Hi

I have a little javascript counter on my dashboard that counts up. this all works nicely with fixed values, but, when i try to enter a dynamic value it says NaN

I have this code

<h1 class="card-text counter" dmx-bind:data-target="SC_DashboardCounters.data.NoClients.NoClients">0</h1>

<h1>&nbsp;clients{{SC_DashboardCounters.data.NoClients.NoClients}}</h1>

i have the SC_ part twice as i wanted to check i got the right count from my query which i do.

I have the count set using dmx.bind but it doesn´t seem to like it.

any thoughts or examples of counters I could utilise that will work with dynamic numbers?

thanks

Hello James!

NaN = Not a number, so what about this:
SC_DashboardCounters.data.NoClients.NoClients.toNumber() ?

thanks for the reply, yeah I tried that, didn´t work, i think its probably to do with the javascript trying to run before the query has the number it requires for the counter, as, even if i just display SC_DashboardCounters.data.NoClients.NoClients.toNumber() it initially says NaN until i guess the query has run to get the numer

it is what i thought, query not running quick enough for the script, i put a setTimeout on the script to make it was a second and now it works :slight_smile:

Try this

SC_DashboardCounters.data.NoClients.NoClients.toNumber() || 0