5
votes

Just starting to use SlickGrid and it doesn't seem to initiate itself like a normal jquery widget/plugin does where you can access the instance attached to the element by just doing $(element).slickgrid() .

Is there a way to get a hold of the existing instance, without obviously holding onto it when you create it? Looking through the code it didn't seem like it, but wasn't sure if anybody else had run into this.

Not exactly sure why they took dependencies on jquery but decided to have a custom initialization.

Could be as simple as just wrapping it in a jqueryui widget.

2

2 Answers

9
votes

You could always use jQuery's data function to save a reference to the slick grid instance.

For example:

var grid = new Slick.Grid(container,data,columns,options);
$(element).data('slickgrid', grid);

And you can access it using:

$(element).data('slickgrid');
-2
votes

I find these kinds of questions kinda funny. Just because something uses the jQuery library, it doesn't automatically make it a jQuery plugin or a jQueryUI widget. SlickGrid is neither, which is why it doesn't follow their design conventions or APIs.

That minor rant aside, Mark's answer is correct. If for some reason you want to store the instance variable with the DOM element, you can easily do that with $(element).data().