Search code examples
jqueryresizeflotgridster

Is it possible to add resize handler to existing widget?


The gridster initialization has been abstracted away from me. Unfortunately, my content contains a Canvas plot (using Flot, if it matters) so it gets very ugly when the Gridster widget gets resized.

I can get hold of the Gridster object (via a JQuery selector), but I can't seem add a resize listener, since my Gridster widget has already been initialized.

JQuery UI's .resize() seems to be ignoring me, so I think the event isn't propagated? Or maybe it uses a different event type?

Short of re-initializing the whole Gridster Resizeable object, is the a way to bind a resize handler?


Solution

  • If you need to define the callback after initialization you can do it in the options property:

    var myGrid = $(".gridster ul").gridster().data('gridster');
    myGrid.options.resize.resize = function(){
       // do something awesome here
    }