Skip to content

Conversation

@shprink
Copy link

@shprink shprink commented May 22, 2015

We had a need to programmatically have access to internal controller functions.

Handling several instances of Gridster

I added a delegate handle attribute to name your gridster instance (not mandatory)

<div gridster="gridsterOptions" delegate-handle="myGridster">

Get Gridster instances (via GridsterDelegate factory)

With the GridsterDelegate factory you can within your controller get any gridster instance like this:

GridsterDelegate.getByHandle('myGridster')

If you havent specify any handle

GridsterDelegate.getByHandle()

Get GridsterItem instances

GridsterDelegate.getByHandle(delegate).getItemInstances()

Use cases

Change the size of all items programmatically

GridsterDelegate.getByHandle().getItemInstances().forEach(function(item){
item.setSizeY(5);
})

Demo

http://codepen.io/shprink/pen/NqRLRB

@shprink
Copy link
Author

shprink commented May 23, 2015

@danomatic let me know what you think. Then I can help fixing the tests.

@ByJC
Copy link

ByJC commented Jun 3, 2015

+1,
I think it's a nice way to manage the items.
maybe we could try to fix the tests and merge it ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants