I'm trying to create a dynamic navigation bar in ember. I have a partial header included in application template which have an element 'search' that should be only visible when I get to my events index route. I have tried to do that this way:
ApplicationController = Ember.Controller.extend(
eventsIndexController: Ember.inject.controller 'events/index'
isSearchActive: Ember.computed 'eventsIndexController.showSearch', ->
@get 'eventsIndexController.showSearch'
And in events index controller:
EventsIndexController = Ember.Controller.extend(
showSearch: false
When it gets to events index route
EventsIndexRoute = Ember.Route.extend(
model: ...
setupController: (controller, model) ->
controller.set('model', model)
controller.set('showSearch', true)
deactivate: ->
@controllerFor('events.index').set('showSearch', false)
And it works fine - model is set properly and search option is only visible in events index route. The problem is that I would like to perform some action when search is clicked but since this action is declared in EventsIndexController I can't call it in normal way from application template. So my first question is:
- do you know how to achieve that?
And second question is:
- how can I accomplish what I'm trying to do in better way because it doesn't seem to be very clear way and it might get really complicated in a course of time when I'll need new dynamic segments.
Aucun commentaire:
Enregistrer un commentaire