Using Polymer 1.0
I'm trying to change an paper-icon-button's (Polymer) icon on click. Can't get it working.
I've done this so far.
<paper-icon-button class="expandComments"
icon="{{isCollapsed? 'expand-more' : 'expand-less'}}" on-click="expanding">
</paper-icon-button>
'expand-more and 'expand-less' is the icons i want to use.
Created function:
created: function() {
this.isCollapsed = true;
},
Expanding function:
expanding: function() {
var content = this.$.review_item_content;
if(content.classList.contains('review-item-content')) {
this.isCollapsed = false;
content.classList.remove('review-item-content');
}else{
this.isCollapsed = true;
content.classList.add('review-item-content');
}
},
it gets to the expanding function and changing the value of isCollapsed and removes the style class.
Now I've also tried this one:
<paper-icon-button class="expandComments" icon="{{expandIcon}}" on-click="expanding"></paper-icon-button>
icon: {
expandIcon: 'expand-more',
},
created: function() {
this.isCollapsed = true;
},
expanding: function() {
var content = this.$.review_item_content;
if(content.classList.contains('review-item-content')) {
this.icon.expandIcon = 'expand-less';
this.isCollapsed = false;
content.classList.remove('review-item-content');
}else{
this.icon.expandIcon = 'expand-more';
this.isCollapsed = true;
content.classList.add('review-item-content');
}
},