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.03k stars 1.2k forks source link

remove_widget console error #229

Open gertjanwytynck opened 11 years ago

gertjanwytynck commented 11 years ago

I'm trying to remove all the widgets with the class 'extraColumn1'. (I have 4 widgets with this class).

My code: gridster.remove_widget($('.extraColumn1'));

All the widgets are removed but I got an error in the console -> (4) 'Uncaught TypeError: Cannot read property 'row' of undefined'

I did this-> https://github.com/ducksboard/gridster.js/issues/63 but no success..

Thanks in advance!

jessleecuizon commented 11 years ago

I get the same error when executing remove_widget function.

activeworx commented 11 years ago

Here is an example on how to remove a widget:

var gridster = $('.gridster ul').gridster(...).data('gridster'); gridster.remove_widget($("#widget_one"));

iuliux commented 10 years ago

I encountered this too.

I'm removing 2 widgets in a for-statement, like this:

for (k in views){
    var el = $('#' + k);
    if (!views[k]) {
        gridster.remove_widget(el, false);
    }
}

The widgets are on the same column, they get removed, the widget below moves up 1 (just 1) row. Then, whenever I drag a widget over the empty cell (where the top widget died) it throws me the exception @gertjanwytynck is having.

crashbtz commented 9 years ago

+1

Benjarmil commented 9 years ago

+1

rajivmg commented 9 years ago

+1

adammatthewsmith commented 9 years ago

+1

Godoy commented 8 years ago

Solve to me:

      gridster = $('.gridster ul:first').data('gridster')
      gridster.remove_widget($(@node).parent(), true)
      $(@node).empty()
hasekrx commented 6 years ago

In my application i had to remove the Element from the dom after use the remove_widget function and put a validation to prevent the card to moveup inside the remove_widget function in this part:

$el.fadeOut($.proxy(function() {
    $el.remove();
    $nexts.each($.proxy(function(i, widget) {
        if($(widget).coords().grid)
        {
            this.move_widget_up( $(widget), wgd.size_y );
        }
    }, this));

inside the $next.each i did a validation verifying if the coords are not undefined and never had the problem again! i don't think this is the better solution but it is working :)