rasmusbergpalm / jslate

Write your dashboards in pure html/js
jslate.com
244 stars 54 forks source link

$wid not unique causing rendering issues #54

Closed n7k1 closed 10 years ago

n7k1 commented 10 years ago

I'm having a problem where the DIV IDs ($wid) are not unique in the dashboard. It's causing the widgets to display in the wrong box. I can workaround the problem by hardcoding a div id and not using $wid. Any ideas what I've done wrong in the installation? I'm running it in a WAMP stack.

Thanks.

n7k1 commented 10 years ago

It looks like $wid = 'id_'.uniqid(); isn't producing a unique identifier on my system. I'll play with it a little.

rasmusbergpalm commented 10 years ago

Weird. Maybe you can use microtime or nanotime or a hash of the widget contentns. Please let us know if you find a solution, and why uniqid() is not unique. And extra points for a pull request! :)

n7k1 commented 10 years ago

As dumb as this solution may be, it seems to work. SRAND or MT_STAND doesn't work. Apparently, it's a Windows thing.

Edited: \metricserver\c$\BitNami\wampstack-5.4.24-0\apache2\htdocs\measure\app\View\Dbviews\add.ctp

$code = strreplace('${wid}', "id".uniqid(), $code);

$code = strreplace('${wid}', "id".mt_rand(), $code);

Edited: \metricserver\c$\BitNami\wampstack-5.4.24.0\apache2\htdocs\measure\app\View\Dashboards\view.ctp

$wid = 'id_'.uniqid();

$wid = 'id_'.mt_rand();