Polymer Ready call back does not see user changed attribute

77 views
Skip to first unread message

Just.A.Guy

unread,
Mar 30, 2014, 5:44:31 PM3/30/14
to polym...@googlegroups.com
I probably do not understand how polymer works.
I was (am) under the impression that the "ready"
callback routine is invoked after the template
has been instantiated in the shadow DOM.

I have created a component on JsBin in member "rapoq/1".
It show how the rendering of the modified public attributes
effect the HTML output.
But if you look at the Console log, that is produced
from the "ready" call back routine. The default value 
for the attribute is still present.   I was expecting
that the changed value would have been present
to the "ready" callback.

I thought that processing in the ready routine
was to customize the element before it appeared
in the rendered page.  If you cannot see the 
users input from the modified published values,
then why have them?  

Maybe I am using the wrong callback. Maybe
I should be using the "attached" callback.
But by its name (attached), it seems to imply
that the custom element has already completed
its rendering process.  This would seem to be
a little late form making layout/size modifications.

By the way, I have experienced this same condition
in the latest version I have on my laptop. I do not
know if JsBin has the latest version. But it does
not seem to matter.    

Scott Miles

unread,
Mar 30, 2014, 6:13:36 PM3/30/14
to Just.A.Guy, polymer-dev
1. Send JSBin examples as regular links, for example:


2. You didn't use the script and import includes that are shown in the starter project I sent you. For best results, you should stick with my suggestions.

3. When you declare `opts` and `init` externally like you did, you invite additional complexity. Suggest you stick with the basic inline syntax as shown in the example above. You can expand your vocabulary when you get stronger with JavaScript.

4. The object sent to the Polymer function (`opts` in your example) becomes a _prototype_ for creating instances. All instances share a prototype, but changed values are only available on `this` (so that each instance can have it's own state). So, instead of `opts.max_length' you should be logging `this.max_length`.

I believe the jsbin linked above demonstrates the behavior you are looking for.


Follow Polymer on Google+: plus.google.com/107187849809354688692
---
You received this message because you are subscribed to the Google Groups "Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to polymer-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/33449882-1a68-4608-8489-f5ce4ce2604f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages