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

Gridster not adding widgets where i want #549

Open ionHive opened 8 years ago

ionHive commented 8 years ago

I'm trying to dynamically add widgets to gridster using add_widget method. My code is as follows: gridster = $(".gridster ul").gridster({widget_selector: "li", widget_margins: [5, 5], widget_base_dimensions: [120, 40], min_cols: 0, min_rows: 0, max_size_x: false, avoid_overlapped_widgets: true}).data('gridster');

gridster.add_widget('<li><div>'+docItem.description+'</div><div>'+docItem.vals+'</div></li>', 1, 1, docItem.col, docItem.row);

I get the following as HTML when i use (col, row) as (1,1) and (2,2) in add_widget:

`

  • Total
    1
  • John
    2

`

What is happening here?

vticky commented 8 years ago

What I noticed if I have this structure:

you have to add widget this way:

gridster.add_widget('< div class="gridster ready" >', 1,1,1,1)