ducksboard / gridster.js

gridster.js is a jQuery plugin that makes building intuitive draggable layouts from elements spanning multiple columns
http://gridster.net/
MIT License
6.04k stars 1.2k forks source link

'row' is null or not an object - Removing a widget causing javascript issues (widgets_below(); function) #449

Open Dicko21 opened 9 years ago

Dicko21 commented 9 years ago

Hi,

Have just recently created a dashboard framework using gridster.js and so far everything is working as expected. My problem starts with needing to support IE8, which it manages fine up until I need to remove a widget from the dashboard. Using remove_widget() works perfectly on all other major browsers and later versions of IE, but IE8 will error when calculating the rows below the removed widget.

The function remove_widget(); calls

var $nexts = this.widgets_below($el);

with $el at that point showing up as:

{"length":1,"prevObject":{"length":1,"selector":"#dashboard_widget_1095_8"},"selector":"#dashboard_widget_1095_8.parent()"}

But once it hits the function widgets_below() and goes through:

var el_grid_data = $.isPlainObject($el) ? $el : $el.coords().grid;

el_grid_data is returned as undefined, but only in IE8. Looks like $el.coords().grid is the cause. Does anyone know of this issue or if a workaround is available?

EDIT: IE8 is reporting that when the grid is initialised, the coords function is returning a bunch of values (for the faux grid):

{"length":1,"0":{"left":466.5,"top":1471,"width":172,"height":144,"col":3,"row":9,"original_col":3,"original_row":9}}

Which contains the 'row' variable used by the other functions, yet the $el var doesn't contain those values...?

Cheers.

adeebshihadeh commented 9 years ago

If you are still having this issue, the problem for me, was that I was using $.empty before .remove_all_widgets. using $.empty after fixed it for me.