Giter VIP home page Giter VIP logo

Comments (10)

notwaldorf avatar notwaldorf commented on June 30, 2024 1

@ghawkins-pulsemining For displaying buttons veritcally, all you need is to set display:inline-block:

paper-radio-button {
  display: inline-block;
}

Looks like this:
screen shot 2015-06-15 at 2 23 32 pm

from paper-radio-group.

jlg7 avatar jlg7 commented on June 30, 2024

+1 regarding the usage of paper-radio-group with dom-repeat. The distributed dom does not appear ready when the index is obtained. If a domReady event still isn't available, perhaps flushing the dom using Polymer.dom.flush() or adding addl. latency to the async might be needed when selected is changed.

from paper-radio-group.

m4b avatar m4b commented on June 30, 2024

I've noticed similar problems when using a dom-repeat inside a <paper-radio-group>; it reports an error on the checked attribute for some reason.

from paper-radio-group.

ronnyroeller avatar ronnyroeller commented on June 30, 2024

The workaround proposed by @jongeho1 did the trick for us: Have the application wait until the browser event loop returns before setting the 'selected' property.

from paper-radio-group.

ronnyroeller avatar ronnyroeller commented on June 30, 2024

I identified another issue with <paper-radio-group> and dom-repeat: The paper-radio-button sets the _selectedIndex to 0 at initialization. At that point of time, nodes[0] is the template. Hence the paper-radio-group sets the checked attribute on the template instead of the first paper-radio-button.
Worse, it's now no longer possible to select the first paper-radio-button because paper-radio-group._selectIndex checks if the requested new index is the same as the formerly set index.
Deactivating this check works around this issue:

     _selectIndex: function(index) {
-      if (index == this._selectedIndex)
-        return;
+      // Workaround for bug https://github.com/PolymerElements/paper-radio-group/issues/8
+      //if (index == this._selectedIndex)
+      //  return;

       var nodes = this.items;

from paper-radio-group.

notwaldorf avatar notwaldorf commented on June 30, 2024

@ghawkins-pulsemining I think the original issue is fixed in the latest release (1.0.2). Would you mind double checking it's okay on your end? Thanks!

from paper-radio-group.

m4b avatar m4b commented on June 30, 2024

confirmed this fixed on FF and Chrome, nice job. I can't seem to initially select the first element (I can initially select the 2nd, 3rd, etc.), but quickly testing, so could be something else.

from paper-radio-group.

notwaldorf avatar notwaldorf commented on June 30, 2024

Yay! I had this, which selects the first item on all the things, so maybe your example is grumpy:

<template is="dom-bind" items="{{sizes}}" id="t">

  <paper-radio-group selected="Small">
    <template is="dom-repeat" items="{{sizes}}">
      <paper-radio-button name="{{item.name}}" >{{item.name}}</paper-radio-button>
    </template>
  </paper-radio-group>

  <paper-radio-group selected="Large">
    <template is="dom-repeat" items="{{sizes}}">
      <paper-radio-button name="{{item.name}}" >{{item.name}}</paper-radio-button>
    </template>
  </paper-radio-group>

  <script>
    document.getElementById('t').sizes = [{name:'Small'},{name:'Medium'},{name:'Large'}];
  </script>

</template>

from paper-radio-group.

m4b avatar m4b commented on June 30, 2024

selected="1" seems to work fine, etc. Maybe cause I'm using [[index]] (not even sure if that's allowed anymore 😮 )

<dom-module id="radio-group">
  <style>
  </style>
  <template>
    <paper-radio-group selected="0">
      <template is="dom-repeat" items="[[data]]">
        <paper-radio-button name="[[index]]">[[item.title]]</paper-radio-button>
      </template>
    </paper-radio-group>
    <iron-ajax auto url="http://jsonplaceholder.typicode.com/posts" handle-as="json" last-response="{{data}}">
    </iron-ajax>
  </template>
  <script>
    Polymer({
      is: 'radio-group',
      properties: {
        data: {
          type: Array,
          notify: true,
          observer: 'dataChanged'
        }
      },
      dataChanged: function(data) {
        console.log(data);
      }
    });
  </script>
</dom-module>

from paper-radio-group.

notwaldorf avatar notwaldorf commented on June 30, 2024

Awesome! Closing this! 💃 🎉

from paper-radio-group.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.