Ember outlet bound to StateManager doesn't render after changing state twice

不问归期 提交于 2019-12-05 10:46:13
Wojciech Bednarski

The reason why it doesn't work is because you have two DOM nodes with id index. In your fiddle is extra </script> at the end of HTML pane but it doesn't matter I guess.

ID in DOM must be unique, otherwise you can see some unexpected issues like this one. You can read more here https://developer.mozilla.org/en/docs/DOM/element.id

Here is working fork of your fiddle - http://jsfiddle.net/wbednarski/eMcXq/

BTW, You may find helpful as well - Difference between == and === in JavaScript

You are not transitioning out of your router, but are only changing the state of your LoginStateManager. If you include the routing output in your App creation, you will see the output, and the lack of transitioning out of your "welcome" state.

Just change App to:

App = Ember.Application.create({ LOG_TRANSITIONS: true });

You will see that using your login-button on the navBar will perform the correct function once, where the button on the login form doesn't transition state, and therefor doesn't show the correct result. This is because in the App.NavBarController you perform this.transitionToRoute("welcome").

Just extend all your logins and logouts with: this.transitionToRoute("welcome") or this.transitionToRoute("index") and it works like a charm.

[edit] Added an example fiddle here: http://jsfiddle.net/AlphaEagle/rGNca/4/ Hope it helps! [/edit]

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!