I'm not entirely sure this addresses your question, but it sounds
similar to an issue Aaron assisted me with.
I will assume that you have:
- a Class 'GridView'
- a Class 'GridPreview'
- a Behavior 'Grid'
- a Behavior 'Preview'
The theory is to use the Behavior API as an event arbitrator between
your GridView and GridPreview classes, like this:
Behavior.addGlobalFilter('Grid', function(el, api) {
// create your GridView class
var myGridView = ...
myGridView.addEvent('complete', function() {
api.fireEvent('gridRendered', {}); // I'm passing empty args, but
you may need to pass something substantial
})
});
Behavior.addGlobalFilter('Preview', function(el, api) {
// create your GridPreview class
var myGridPreview = ...
api.addEvent('gridRendered', function(args) {
myGridPreview.preview(args)
});
});
The pattern above has worked well for me working with classes that
deal with fetching server-side data and a pagination class.
Regards,
Eric
On Oct 9, 7:18 am, Rolf Langenhuijzen <[email protected]> wrote:
> (Hi Aaron,)
>
> Apologies for this non-focused subject, but I couldn't think of a
> shorter to the point one..
>
> Here's my case slightly modified/simplyfied:
> 1. I have a simple list with items. These items are just text, like
> names of people. I also add a data-image="my-image.jpg" to the list
> element.
> 2. With a class I turn this into a grid view and it fires an
> onComplete. In the onComplete I trigger a pagination class that turns
> the grid in X pages in a smaller viewport and some controls.
> 3. I use the onComplete from the paginate class to trigger a final
> class (preview) that enriches the grid with images using the data-
> attribute.
>
> Let's cut out 2 for now (the pagination part).
>
> When I use Behavior to create the grid. How should I use the complete
> event to trigger the 'preview' class for the elements in the grid?
> The preview class is dependent on the grid.. if there's no grid, there
> are no images.
>
> Rolf