简体   繁体   中英

Mustache.js is not rendering disabled attribute inside html tag. But it is rendering correctly elsewhere

Why is it that mustache is not working for attributes? I have the value of the variable disableConfirmado to be 'disabled'. I have this template:

 <td>
        <button {{disableConfirmado}} class="btn-sm confirmar_periodo {{disableConfirmado}} btn-info btn">Confirmar</button>
    </td>

but when it renders, it only renders it in the class part and puts a weird string inside the html tag.

<td>
        <button =""="" class="btn-sm confirmar_periodo disabled btn-info btn">Confirmar</button>
    </td>

What would be right way to do this? (I want to disable the button based on a value I get before)

Okay found the problem, you have to use lower case for the variable if you its going to be an attribute and the template is defined in html.

Since html attributes are case insensitive it was converting disableConfirmado to disableconfirmado. It was not doing this inside the Class because classes are case sensitive.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM