ivylabs / IvyDC

IvyDC - Ivy Dashboard Components
http://www.ivy-is.co.uk
Mozilla Public License 2.0
5 stars 10 forks source link

BUG: Solved "TypeError: Cannot read property 'length' of undefined" e… #47

Open JohnEricson opened 9 years ago

JohnEricson commented 9 years ago

Solves "TypeError: Cannot read property 'length' of undefined" error when using slider connected to datasource in CDE dashboard. The cause of the problem is that sliderData.resultset.length is executed before sliderData = values, resulting in the slider failing to render on start of the dashboard.

Complete error:

CDF: Error updating render_SliderYear:Dashboards.log @ Dashboards.Main.js?v=8e89e10f9ca55858977d99c20148f7a6:82
    (anonymous function) @ Dashboards.Main.js?v=8e89e10f9ca55858977d99c20148f7a6:403
    setTimeout (async)Dashboards.updateLifecycle @ Dashboards.Main.js?v=8e89e10f9ca55858977d99c20148f7a6:415
    Dashboards.updateComponent @ Dashboards.Main.js?v=8e89e10f9ca55858977d99c20148f7a6:459Dashboards.updateAll @ Dashboards.Main.js?v=8e89e10f9ca55858977d99c20148f7a6:1127
    Dashboards.initEngine @ Dashboards.Main.js?v=8e89e10f9ca55858977d99c20148f7a6:880(anonymous function) @ Dashboards.Main.js?v=8e89e10f9ca55858977d99c20148f7a6:690
    fire @ jquery.js?v=08c235d357750c657ac1db7d1cf656a9:1037
    self.fireWith @ jquery.js?v=08c235d357750c657ac1db7d1cf656a9:1148
    jQuery.extend.ready @ jquery.js?v=08c235d357750c657ac1db7d1cf656a9:433
    completed @ jquery.js?v=08c235d357750c657ac1db7d1cf656a9:103
Dashboards.Main.js?v=8e89e10f9ca55858977d99c20148f7a6:85
    TypeError: Cannot read property 'length' of undefined
    at BaseComponent.extend.update (ionRangeSliderComponent.js?v=47871653d5a1943b738b951940888bc8:48)
    at Object.<anonymous> (Dashboards.Main.js?v=8e89e10f9ca55858977d99c20148f7a6:378)
JohnEricson commented 9 years ago

My bad! This doesn't really solve the problem. Now it uses the hardcoded minRange, maxRange in properties instead of taking them from the datasource query.

JohnEricson commented 9 years ago

Now I've fixed so the solution works with datasource queries as earlier. I would like this fix to be pulled into master.

latinojoel commented 9 years ago

Hi @JohnEricson,

Thanks for your contribution. :smile: I'll give a test soon.

Joel