I have an application using ember with two tabs, one for articles
, and other for hotArticles
. Here's the template:
<a class="item" data-tab="hot">Hot</a>
<a class="item active" data-tab="all">All</a>
<div class="ui tab" data-tab="all">
{{article-list articles=articles}}
</div>
<div class="ui tab" data-tab="hot">
{{article-list articles=hotArticles}}
</div>
articles
is supposed to return api/articles
, and hotArticles
is supposed to return api/articles?filter=hot
, here's the route and controller:
export default Ember.Route.extend({
model: function() {
return this.store.find('article');
}
});
export default Ember.ArrayController.extend({
articles: function() {
return this.get('model');
}.property('model'),
hotArticles: function() {
return this.store.find('article', { filter: 'hot' });
}.property('')
});
This is fundamentally wrong. Obvious problem is when the page is loaded, both requests are made but hotArticles
should not be loaded until the tab is selected.
One possible solution might be to separate the routes for each tab, but that will break the template. The tab functionality works without introducing any routes and I want it to keep it that way. Specifically I am using semantic-ui tabs.