Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bind to a core-list item's `hidden` attribute (Polymer 0.5)

Tags:

polymer

Digging into the core-list source code, it looks like it checks an element's hidden attribute using Javascript. But setting <div hidden="false"> results in the div being hidden. Can I somehow bind an expression to this Javascript attribute or do I need to submit a PR to core-list to explicitly add support?

like image 579
Indolering Avatar asked Apr 16 '15 02:04

Indolering


2 Answers

You can hide / show polymer elements with the hidden? attribute.

<span hidden?="{{showSpan}}">This may or may not be hidden.</span>

if the boolean expression 'showSpan' is truthy, the span element is displayed, otherwise it is omitted.

You can toggle the state of showSpan like this:

<div on-click="{{showinput}}">
   <span hidden?="{{showSpan}}">This may or may not be hidden</span>     
</div>



 Polymer({

       showSpan: false,

       showinput: function() {
         this.showSpan = !this.showSpan;
         }
     });
like image 177
martin Avatar answered Nov 14 '22 12:11

martin


If you want that your element not being hidden you should remove the hidden attribute. hidden="false" does not means much in html.

like image 45
Florian ROY Avatar answered Nov 14 '22 12:11

Florian ROY