javascript - Ember.js: Howto create routes that only execute code -
my app has main view hidden elements can activated user. typical sidebar on mobiles slides in left. or cart reveals details when tap on it.
the information in hidden elements date since content mapped in main app template. routes not need render dom.
the transitions js based. want states reflected in url, in order consistent button behavior.
how can achieve using ember framework?
update make more clear, talking about:
to understanding triggering routes in ember has 2 side-effects:
- represent new state in url, enabling consistent browser history support.
- render templates manipulate dom based on data
in case, when instance user taps on minimized cart need:
- represent new state in url, enabling consistent browser history support.
- execute
showcart()
js function (no dom changes, no template rendering)
when user taps on browser button, closecart()
should executed (based on fact state in url carries information cart open).
you can use activate
, deactivate
methods show route, know when entered or exited route:
app.showroute = ember.route.extend({ activate: function() { alert('entering in show'); // here showcart }, deactivate: function() { alert('exiting show'); // , here closecart } });
i created live demo here, see working.
Comments
Post a Comment