Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mdl-radio the default values are not set #150

Open
IgnatVarlamov opened this issue Aug 1, 2016 · 1 comment
Open

mdl-radio the default values are not set #150

IgnatVarlamov opened this issue Aug 1, 2016 · 1 comment

Comments

@IgnatVarlamov
Copy link

IgnatVarlamov commented Aug 1, 2016

"ember": "2.4.5"
chrome mac 51.0.2704.106 (64-bit)
chrome ubuntu 52.0.2743.82 (64-bit)

Im extend mdl-radio in my code and add add this logic:

export default MdlRadio.extend({
  onChange: on('change', function() {
    set(this, 'groupValue', get(this, 'value'));
  }),
  onInsert: on('didInsertElement', function() {
    if (get(this, 'groupValue') === get(this, 'value')) {
      this.$('input').attr('checked', '');
    }
  })
});

groupValue - input param. It may be 'enabled' || 'disabled' || 'default'
when groupValue is equal to value of radio button i do this this.$('input').attr('checked', ''); to set values by default

This code worked on all browsers by mac os but doesn't work at chrome by linux.

I fix it in the following way

export default MdlRadio.extend({
  onChange: on('change', function() {
    set(this, 'groupValue', get(this, 'value'));
  }),
  onInsert: on('didInsertElement', function() {
    Ember.run.scheduleOnce('afterRender', this, () => {
      if (get(this, 'groupValue') === get(this, 'value')) {
        this.$('input').attr('checked', '');
        this.$().addClass('is-checked');
      }
    });
  })
});
MaterialRadio.prototype.checkToggleState = function () {
    if (this.btnElement_.checked) {   // always false!!!
        this.element_.classList.add(this.CssClasses_.IS_CHECKED);
    } else {
        this.element_.classList.remove(this.CssClasses_.IS_CHECKED);
    }
};
@IgnatVarlamov
Copy link
Author

today updated chrome on macos to 52.0.2743.82 (64-bit) and have this problem on mac

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant