We still haven't covered the key question, which is whether the values you are sending in to the pager really need to be _bound_ (that is dynamic) or whether they just need to be sent in one time. If you don't need them to be fully dynamic, it's all pretty easy:
http://jsbin.com/hoteba/2/edit Minor notes: - this.textContent = '' is a simpler way of removing all the children than your while loop, you certainly don't need both - the bindings you have to custom-pager in your example don't do anything, I removed them for clarity On Fri, Sep 5, 2014 at 11:36 AM, Paul Hodges IV <[email protected]> wrote: > Hopefully this explains it a little better: > http://jsbin.com/mikexeluwixe/1/edit > > On Friday, September 5, 2014 1:35:28 PM UTC-4, Scott Miles wrote: >> >> It's not entirely clear what kind of stuff you want to pass in via >> `attrs`. Live code will help us figure out the details of your use case, so >> below is just a starting place. >> >> As described, you can only pass in static data anyway, so I would start >> like so: >> >> http://jsbin.com/kibife/2/edit >> >> <polymer-element name="custom-pager"> >> >> <!-- for simplicity, let's leave out the template for now --> >> >> <script> >> Polymer({ >> changePage: function(elementname, attrs) { >> var page = document.createElement(elementname); >> for (var k in attrs) { >> page.setAttribute(k, attrs[k]); >> } >> >> // discard old page >> >> this.textContent = ''; >> this.appendChild(page); >> } >> }); >> </script> >> </polymer-element> >> >> <script> >> addEventListener('polymer-ready', function() { >> document.querySelector('custom-pager').changePage('my-page1', >> {attr1: 'boundvarfromelsewheredotcom'}); >> }); >> </script> >> >> >> >> On Fri, Sep 5, 2014 at 10:08 AM, Paul Hodges IV <[email protected]> >> wrote: >> >>> HI! I've created a <custom-pager> element which dynamically creates >>> polymer-element instances on the fly (instead of having to preload >>> elements.) Ex (note, this is concept only, probably has bugs): >>> >>> <polymer-element name="my-page1" attributes="attr1" noscript> >>> <template> >>> Page1 {{attr1}} >>> </template> >>> </polymer-element> >>> >>> <polymer-element name="my-page2" attributes="attr2" noscript> >>> <template> >>> Page 2 {{attr2}} >>> </template> >>> </polymer-element> >>> >>> >>> <polymer-element name="custom-pager"> >>> <template></template> >>> <script> >>> Polymer({ >>> changePage(elementname, attrs) { >>> //...other code >>> var div = document.createElement('div'); >>> div.innerHTML = '<' + elementname + '></' + elementname + '>'; >>> for(var k in attrs) { >>> div.children[0][k] = attrs[k]; >>> } >>> this.appendChild(div); >>> } >>> }); >>> </script> >>> </polymer-element> >>> >>> >>> <custom-pager></custom-pager> >>> <script> >>> window.addEventListener('polymer-ready', function() { >>> document.querySelector('custom-pager').changePage('my-page1', {attr1: >>> '{{boundvarfromelsewheredotcom}}'}); >>> }); >>> </script> >>> >>> The issue is, i dont know which attributes the developer, using my >>> custom-pager, needs to be passed + bound into the page "my-page1". >>> >>> Question is, is there a way to have custom-pager automagically bind to >>> all attributes so that they can be passed on to the pages (so one could >>> specify <custom-pager attr1="{{attr1value}}" attr2="{{attr2value}}"/> )? >>> Or is there a way to publish the attribute (per element instance, not >>> prototype) on-the-fly (which would look like <custom-pager >>> attr1="{{attr1value}}" attr2="{{attr2value}}" bindToAttributes="attr1 >>> attr2"/> )? >>> >>> Thanks peeps! >>> >>> p4 >>> >>> 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 [email protected]. >>> To view this discussion on the web visit https://groups.google.com/d/ >>> msgid/polymer-dev/c649f93b-e859-4c07-8735-1c89c6fc0882% >>> 40googlegroups.com >>> <https://groups.google.com/d/msgid/polymer-dev/c649f93b-e859-4c07-8735-1c89c6fc0882%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/polymer-dev/fb3c9645-9fcb-434a-9057-72ac68aca53b%40googlegroups.com > <https://groups.google.com/d/msgid/polymer-dev/fb3c9645-9fcb-434a-9057-72ac68aca53b%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/CAHbmOLZ8ftHzu-56H3D0iq5ctqBaSdLCocp38B5ZAChGP%3D0cfQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
