Gridster.js可拖动销毁后不起作用?

时间:2018-06-27 07:48:35

标签: jquery gridster angular-gridster2 angularjs-gridster

尝试重新启动gridster dynamically,但似乎gridster draggble在销毁并重新创建后无法正常工作。看看我的代码。

var gridster;
function initGridster() {
    gridster = $(".gridster").gridster({
        widget_margins: [5, 5],
        widget_base_dimensions: [500, 300],
        autogrow_cols: true,
        max_cols: 2,
        shift_widgets_up: false,
        shift_larger_widgets_down: false,
        collision: {
            wait_for_mouseup: true
        },
        draggable: {
            stop: function (e, ui) {
                var id = this.placeholder_grid_data.el[0].id;
                var positions = this.player_grid_data;
                var data = { widgetId: id, position: positions };
             }  
        }
    }).data('gridster');
}
initGridster(); //First time init gridster
gridster.destroy(); //destorying
initGridster(); // Re initiating , but draggable doesn't work anymore

0 个答案:

没有答案