Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

polymer-localstorage-load only fires if the value has previously been set #404

Closed
balupton opened this issue Jan 24, 2014 · 2 comments
Closed

Comments

@balupton
Copy link

I have this code:

<polymer-localstorage name="my-name" value="{{myName}}" polymer-localstorage-load="{{getName}}"></polymer-localstorage>
getName: function(){
                while ( !me.myName ) {
                    me.myName = prompt('What is your name?');
                }
            },

But getName never fires if the local storage value hasn't been already set. I would expect that getName always fires, as soon as the value has been fetched, even if the value is undefined.

As originally I had the following in the ready event:

                while ( !me.myName ) {
                    me.myName = prompt('What is your name?');
                }

But the localstorage element hadn't fetched the value yet, so I tried to use the load event instead, but to the same failure.

@frankiefu
Copy link
Member

the event name needs to prefix with on-

<polymer-localstorage name="my-name" value="{{myName}}" on-polymer-localstorage-load="{{getName}}"></polymer-localstorage>

More info here:
http://www.polymer-project.org/polymer.html#declarative-event-mapping

@balupton
Copy link
Author

😳 whoops, working now! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants