gridster.js: After calling remove_all_widgets, then adding more widgets, I can't drag a widget where an old widget once was.

After calling remove_all_widgets(), then adding more widgets, I can’t drag a widget where an old widget once was.

For example, if I create a grid with 2 rows and 3 columns like so:

+-----+-----+----+
|  1  | 2  |  3 | 
+-----+-----+----+
|  4  | 5  |  6 | 
+-----+-----+----+

Then call remove_all_widgets(), then recreate the same grid as above, I can’t drag any widget onto another widget without getting the below errors (multiple times):

Uncaught TypeError: Cannot read property ‘row’ of undefined

I can however, move a widget below into, say “the third row”, onto 7, 8, and 9.

Thanks in advance for any help.

About this issue

  • Original URL
  • State: open
  • Created 11 years ago
  • Comments: 16

Most upvoted comments

@sniperwolfpk5 thanks for posting the fix. $('.gridster ul').empty() sufficed for me. The following “cleanup routine” seems to work the best:

gridster.remove_all_widgets();
gridster.destroy();
$('.gridster ul').empty();