1

I'm trying to migrate from Bootstrap to Polymer/Paper and I've got a lot of situations where I have to enable/disable buttons that were previously accessed as ButtonElements and then .disabled=true/false.

So for example I've got a paper button I'm trying to access and enable/disable via querySelector as such:

PaperButton nextWeekButton = querySelector("#nextweekbutton");
nextWeekButton.disabled=!_status;

But I am getting the error: type 'HtmlElement' is not a subtype of type 'PaperButton' of 'nextWeekButton'.

I get the same variety of message if I try as an InputElement or ButtonElement. If I try to get it as an HtmlElement then of course I get the "setter 'disabled' is not defined..."

I was going to start playing around with attribute setting but really shouldn't there be a way to do this that's like the ButtonElement? Just want to make sure I am not missing anything.

Update: For now I am doing this

void disableButton(Element _e, bool _status) {
  if(!_status) {
    _e.setAttribute("disabled","true");
  } else {
    _e.attributes.remove("disabled");
  }
}
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
Dan
  • 233
  • 1
  • 2
  • 10

1 Answers1

4

I'm pretty sure the problem is that your code is executed before Polymer is initialized. See https://stackoverflow.com/a/20982658/217408 how to initialize Polymer when you have a custom main method.

Community
  • 1
  • 1
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
  • Thank you! I really badly wanted you to be incorrect with this since I spent too much time trying to figure this out and that was too simple! But that was indeed the issue! I appreciate your direction. – Dan Apr 29 '15 at 19:19