polymer-1.0

Polymer 1.0 Data binding when object changes

大兔子大兔子 提交于 2019-12-04 19:45:54
I'm having trouble understanding how data-binding works now. On my index page I've got an object (obtained as JSON from a RESTful service), which works just fine when applied to a custom element like: <main-menu class="tiles-container ofvertical flex layout horizontal start" menuitems="{{menuitems}}"> </main-menu> var maintemplate = document.querySelector('#fulltemplate'); maintemplate.menuitems = JSON.parse(data.GetDesktopResult); This works as expected, and when I load my page with different users, main-menu changes as it should to show each user's desktop configuration. (This menuitems

How to bind paper-toggle-button to a Boolean in Polymer

北城余情 提交于 2019-12-04 19:10:51
I'm triyng to bind a paper-toggle-button to a boolean but it's not working. I already tried binding with $= and evaluating with ?= . I want to show if the user isActive . <template is="dom-repeat" items={{users}}> <button class="heading" aria-expanded$="[[isExpanded(opened{{index}})]]" aria-controls="collapse{{index}}" onclick="toggle('#collapse{{index}}')" >{{item.firstName}} {{item.lastName}}<paper-toggle-button style="float: right;" checked$="{{item.isActive}}">Activo</paper-toggle-button></button> <iron-collapse id="collapse{{index}}" tabindex="0" opened?="{{opened{{index}}}}"> <div class=

Polymer 1.0: iron-pages not switching pages with children events

大城市里の小女人 提交于 2019-12-04 17:06:26
I have a parent component with two children components in an "iron-pages" component. The parent should switch pages when it receives an event from one of the children. The problem is, when the event arrives at the parent component, it executes the code to switch children but nothing happens. But, if the code is executed on the parent component itself, then it works. My question is: Why the parent component is unable to switch pages when a child sends an event? Below is the code for the two child components: // this is "child-comm.html" <link rel="import" href="bower_components/polymer/polymer

polymer 1.0 how to central justify the paper-card heading?

青春壹個敷衍的年華 提交于 2019-12-04 15:32:36
I am trying this to central justify the paper card heading: paper-card [heading]{ @apply(--center-justified); } but it does not seem to help. kindly suggest heading is not an attribute so you cannot write like that. You basically need to style the .title-text element inside the shadow dom, so use this instead - paper-card::shadow #shadow .header .title-text { display: flex; justify-content: center; } Or use the polymer iron-flex-layout - paper-card::shadow #shadow .header .title-text { @apply(--layout-vertical); @apply(--layout-center); } Update Thanks to @sfeast for pointing it out. Since

Dynamically created html import inside a polymer element (Version 1.0)

亡梦爱人 提交于 2019-12-04 14:13:33
Dynamically created html import inside a polymer element Does anyone know how to dynamically add a html import into a polymer element (version 1.0)? The code below doesn't seem to work and complains that the.. HTML element <link> is ignored in shadow tree. Does anyone know any way around this or know a better way? <!-- here is where the created import could go --> <dom-module id="my-component"> <!-- here is where I'd ideally like the import to be created --> <template> <div id="container"> <!--This is where my dynamically loaded element should be placed--> </div> </template> <script> Polymer(

Polymer 1.0: How to pass an event to a child-node element without using <iron-signals>?

点点圈 提交于 2019-12-04 13:26:34
问题 This Stack Overflow answer suggests using <iron-signals> to broadcast an event down the DOM tree to a custom element. Below, I ask a different question. Question How do I: pass an event down to a direct child node (custom element) from a parent (custom element) without using <iron-signals> ? Code This is what I have so far. But it doesn't work. parent-element.html <dom-module id="parenet-element"> <template is="dom-bind"> <child-element></child-element> <paper-button on-tap="_handleTap"><

Change style programmatically

吃可爱长大的小学妹 提交于 2019-12-04 08:45:14
问题 I'm attempting to follow the Custom property API for Polymer elements docs with regards to updating an element's CSS properties (and styles) programmatically but can't seem to get it working. Here is my current attempt: <link rel="import" href="https://rawgit.com/Polymer/polymer/master/polymer.html"> <dom-module id="my-namecard"> <style> :host { --color: green; } span { color: var(--color, orange); } </style> <template> <div> Hi! My name is <span>{{name}}</span> </div> <button on-click=

How to inject HTML into a template with Polymer 1.x?

无人久伴 提交于 2019-12-04 06:49:44
A part of the template of my Polymer component is supposed to render unescaped HTML from a JSON response (yes, it's safe to do so in this case). I used juicy-html ( https://github.com/Juicy/juicy-html ) for this up until now, but it doesn't work anymore with Polymer 1.x. The corresponding part of my template looked pretty much like this: <template if="{{item.part1}}"> <div> <template is="juicy-html" content="{{item.part1.part2 | callFunction}}"></template> </div> </template> I read about a few solutions for injecting HTML with earlier versions of Polymer, but I'm wondering if there is a

How to two-way bind iron-input to dom-repeat's item?

走远了吗. 提交于 2019-12-04 05:35:23
I just started playing with Polymer 1.0 and am trying to do a very simple binding to collection. I am able to display text within dom-repeat, but the two-way binding to iron-input does not work. I tried array of strings, and objects. No luck. <link rel="import" href="bower_components/polymer/polymer.html"> <link rel="import" href="bower_components/iron-input/iron-input.html"> <dom-module id="hello-world"> <template> <ul> <template is="dom-repeat" items="{{data}}"> <li>{{item.value}}</li> </template> </ul> <ul> <template is="dom-repeat" items="{{data}}"> <li><input is="iron-input" bind-value="{

Add a “dynamic” element with data-binding to my polymer-element

微笑、不失礼 提交于 2019-12-04 05:27:22
问题 For days I try to feed Polymer with some "dynamic" elements :) Unfortunately without success... My goal is to get an element added during runtime and fill it with content by polymer-data-binding (in a "natural" polymer-way. Without a workaround as suggested in another stackoverflow answer.) Please take a look at the code in this fiddle (https://jsfiddle.net/mkappeller/ken9Lzc7/) or at the bottom of this question. I really hope anyone out there is able to help me out. It would also help to