Moving from Polymer v0.5 to v1.0 the registration process for Polymer elements seems different. Prior to Polymer v1.0 we could execute JavaScript code from index.html to initialize all the necessary objects in our Polymer elements . This is a very important detail, because data-binding in Polymer ONLY works correctly when restricted FIRST objects are initialized. This means the following:
For example, if you want to associate an object in the Polymer element with {{ }} or [[ ]] , the object must be defined before registering the Polymer element ! Cm:
<dom-module id="my-elem"> <template> <div>This should be my bounded object: <b>{{obj.name}}</b></div> </template> <script> Polymer({ is: 'my-elem', ready: function () { </script> </dom-module>
The problem is that if the Polymer element BEFORE the app.obj (in the above example this.obj is undefined during the registration of the Polymer element ), then <strong notification> NO will be executed and the update will not be provided even when the app.obj will NOT undefined later.
So, in such cases, we need to initialize the entire bounded object first, before we can use them with {{ }} or [[ ]] .
Is our approach completely wrong? Any suggestions???
source share