add/remove "disabled" for controls (or any attribute) #866
-
|
Hello, how can I add/remove the I loop over a list of pantry items and create a set of unique buttons from it. (here's an early Codepen) Each button has an action to add "its item" to a group add( group(key:sku, quantity:1, label:replace(label,'|',' '), price:price, subtotal:price), bill)
// eventually results in several
{
"key": "frites",
"quantity": 1,
"label": "🍟 Pommes Frites",
"price": 2.5,
"subtotal": 2.5
}
I can find the information if a particular pantry itemis alreday billed by using Thank you. I often use "boolean" data attributes w/o a value in my CSS selectors I have further questions about dealing with the contents of bill and moving it around in the (local) mv-storage, but I'll keep that for another day :D |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Hey there, 👋🏻 Since Mavo is already aware of some boolean attributes (like That's why something like this works out of the box: <button disabled="[5 > 3]">Disabled</button>
<button disabled="[5 > 10]">Enabled</button>However, to make other attributes boolean, we need an extra step — we must tell Mavo that they are boolean, i.e., we need to register those attributes. Mavo API is for the rescue (sorry, I don't know another way to do it without custom JS): Mavo.Elements.register({
"@attribute": {
datatype: "boolean"
}
});For example, to make Mavo.Elements.register({
"@data-foo": {
datatype: "boolean"
}
});To see it in action, see this pen. Hope it helps! P.S. I'm eager to see what you'll get in the end. Your pen looks awesome (to my taste 😉). |
Beta Was this translation helpful? Give feedback.
Hey there, 👋🏻
Since Mavo is already aware of some boolean attributes (like
hidden;disabledon form elements;autoplay,buffered, andloopon<audio>and<video>, etc.), any expression that is resolved to true will add this attribute. If the expression is resolved to false, the attribute will be removed by Mavo automatically.That's why something like this works out of the box:
However, to make other attributes boolean, we need an extra step — we must tell Mavo that they are boolean, i.e., we need to register those attributes. Mavo API is for the rescue (sorry, I don't know another way to do it witho…