You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a template for when the user is logged in and for when the user is logged out, I have a core-ajax component in the template for the login inputs i order to do the login call.
the issue is when the template hides and is displayed (when clicking logout) that the handler won't call anymore.
I found a fix which was to move core-ajax up a level so that it's not affected by the template-if, but could this issue exist with other element which are seen that have to be in a template block?
<polymer-elementname="login" attributes="session"><template><app-globalsid='globals'></app-globals><templateif="{{session == null}}"><inputvalue='{{username}}'/>
<inputtype='password' value='{{password}}'/>
<buttonon-click='{{login}}'>Login</button><core-ajaxid='ajaxlogin' url="{{url}}" handleAs="json" on-core-response='{{handleResponse}}'></core-ajax></template><templateif="{{session != null}}"><buttonon-click='{{logout}}'>Logout</button></template></template><script>Polymer('login',{login: function(){this.url=this.$.globals.LOGIN_URL+'?username='+this.username+'&password='+this.password;// no auto because logout can retrigger ajaxvarajax=this.$.ajaxlogin;ajax.go();},logout: function(){localStorage.removeItem('session');this.session=null;},handleResponse: function(event,response){this.session=response.response.session;localStorage['session']=this.session;}});</script></polymer-element>
also should I just not use core-ajax to access my api and write a service instead (planning on it when the code base gets bigger)
The text was updated successfully, but these errors were encountered:
Polymer currently does not support using automatic node finding (this.$.ajaxlogin) for dynamically created elements. In this case, it works initially because session starts out null and the ajaxlogin element is initially available.
You can correct this in a couple of ways: (1) find the ajaxlogin element in the login method, (2) avoid the problem by simply hiding/showing the 2 ui's instead of using template if which actually regenerates the elements.
var ajax = this.shadowRoot.getElementById('ajaxlogin');
I have a template for when the user is logged in and for when the user is logged out, I have a core-ajax component in the template for the login inputs i order to do the login call.
the issue is when the template hides and is displayed (when clicking logout) that the handler won't call anymore.
I found a fix which was to move core-ajax up a level so that it's not affected by the template-if, but could this issue exist with other element which are seen that have to be in a template block?
also should I just not use core-ajax to access my api and write a service instead (planning on it when the code base gets bigger)
The text was updated successfully, but these errors were encountered: