最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Is there a way to get an instance of SlickGrid from an element - Stack Overflow

programmeradmin6浏览0评论

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.

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.

Share Improve this question asked Apr 6, 2011 at 22:38 Greg RobertsGreg Roberts 2,5621 gold badge20 silver badges23 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 9

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');

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().

发布评论

评论列表(0)

  1. 暂无评论