Hi Daryl,
I am working with two custom extensions; one for audio playback and one for navigation. I started with the navigation extension which renders it's GUI as a fixed position bar at the bottom of the screen containing a row of buttons. this is rendered in the same way as the trickle button using the following
this.$el.appendTo('body');
both extensions check what kindof stuff is on the page to decide whether they will be set up e.g.
Adapt.on('router:page', function(model) {
var availableBlocks = model.findDescendants('blocks');
//if there are blocks on the page then setup extension
if (availableBlocks.length !== 0) {
setupNavigationView(model);
}
});
Next, while developing the audio extension (which contains an audio element and some buttons), i wanted the playback control buttons to go into the same bar(mainly so that it could inherit the CSS of the bar). I was trying to achieve this by changing the render function from this.$el.appendTo('body'); to this.$el.appendTo('.mediaControls'); (mediaControls is the class of a div inside the $el of the navigation extension) but this didn't work because at the point that the audio extension rendered, the navigation extension hadn't rendered yet, so there was no .mediaControls div to append to.
While thinking it through and reading I realised that even if i did get the audio extension to render into the navigation extension, then the audio element would disappear and need to be reinserted every time the navigation extension rendered.
I ended up making another extension which i have called adapt-1-bottomMenu (I added a '1' to make it load first.) this contains a div for each extension to append its view to and also contains all the top level css that I want the extensions to inherit.
having to put a '1' in the extension name still seems a little odd but I'm probably straying a bit from best practices by having the extensions be so interdependent. It works at the moment so I have moved on but i'd be interested to hear if there is a more sensible way of achieving this.
I found this article which discusses sub-views which could be a solution (navigation view and audio view as subviews of bottomMenu view) but I haven't fully grasped it yet
Hope this all makes sense
Gavin