简体   繁体   中英

How to switch/transition an Ember route from third party library?

I'm having difficulty integrating Ember.js with a third party control (fancytree). In this case, I want the tree nodes to show different Ember views on the main content area.

Right now, while rendering the nodes, I'm wrapping them into a tags pointing to '#/a', '#/b', etc.. other option I though of would be using window.location = url; to switch to the appropriate route.

It's working but I'm learning Ember and would like to know if this is the best way of doing this..

Is there an 'Ember' way of doing this? Or what I'm doing is how this is usually done?

Thank you!

I'm not sure if my way is the correct Ember way but it is working for me. I added in the namespace (in my case 'App') the application controller:

App.ApplicationController = Ember.ObjectController.extend({
    init: function() {
        this._super();
        App.controllerHelper = this;
    },
});

You can now call with this helper the transitionToRoute method from everywhere:

App.controllerHelper.transitionToRoute('your route' [, dynamic id]);

I hope this helps and please correct me if there is a better way.

Use the History API . Ember's router should be able to pick up the state changes and transition accordingly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM