Disable attribute in HTML elements
LemonadeJS provides a simple way to control the disabled property of HTML elements.
Example
Source code
<html>
<script src="https://lemonadejs.com/v4/lemonade.js"></script>
<div id='root'></div>
<script>
function Component() {
const self = this;
self.disabled = true;
self.toggle = () => {
self.disabled = !self.disabled;
}
return `<>
<input type="text" :disabled="self.disabled" value="test..." />
<input type="button" onclick="self.toggle" value="Toggle" />
</>`;
}
lemonade.render(Component, document.getElementById('root'));
</script>
</html>
import lemonade from 'lemonadejs';
export default function Component() {
const self = this;
self.disabled = true;
self.toggle = () => {
self.disabled = !self.disabled;
}
return `<>
<input type="text" :disabled="self.disabled" value="test..." />
<input type="button" onclick="self.toggle" value="Toggle" />
</>`;
}