Open ap0091 opened 9 years ago
Just change this lines
function rem(idrem)
{
var rem = grid.remove_widget($(".layout_block").eq(idrem), true);
}
to this lines
function rem(idrem)
{
var rem = grid.remove_widget($("#" + idrem), true);
}
and it will work!
Try this: http://jsfiddle.net/b0ndt/e1Lga24w/2/
Instead of working with ids, work with elements and paths. Note the changed lines:
linkToRemove = '<button onclick="rem(this);">REMOVE</button>';
and
var rem = grid.remove_widget($(idrem).parents(".gs-w"), true);
I have this JSFiddle Here: http://jsfiddle.net/558wsrtb/1/
I have created a gridster to read data from my database (but in this JS Fiddle i have hardcoded the JSON).
I am trying to create functionality to remove a widget, but I occur a bug here and there when I try to remove certain widgets when I am not removing in order.
For example: I can remove Store Chart3, CTC Chart2, Web Chart1, and Store Chart0 in this order successfully.
but then I try to remove Store Chart0, CTC Chart2.. it removes Store Chart 2.. and then if i continue clicking to remove CTC Chart2 nothing happens, but when I click Remove Web Chart 1, CTC Chart2 dissapears..
Do i have an issue with my index values or something or is this a bug? The error from console.log: Uncaught TypeError: Cannot set property 'width' of undefined
Thanks!