JSFiddle - React, Tailwind, and code Playground
HTML
<script src="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.5/handlebars.min.js"></script>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.15/js/bootstrap-multiselect.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.15/css/bootstrap-multiselect.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/gitana/alpaca@1.5.27/dist/alpaca/bootstrap/alpaca.min.css">
<script src="https://cdn.jsdelivr.net/gh/gitana/alpaca@1.5.27/dist/alpaca/bootstrap/alpaca.js"></script>
<div id="myForm">
</div>
<button id="disablefield">
Toggle it!
</button>
JavaScript
$("#myForm").alpaca({
"view": 'bootstrap-edit-horizontal',
"schema": {
type: 'object',
properties: {
'thing': {
"title": "Should be a select",
"type": "string",
"enum": ["foo", "bar", "bizz", "buzz", "boo"]
},
'thing2': {
"title": "Should be a multiselect",
"type": "array",
"enum": ["foo", "bar", "bizz", "buzz", "boo"]
}
}
}
});
let disabled = false;
$('#disablefield').on('click', function() {
const form = $("#myForm").alpaca()
const thing1 = form.childrenByPropertyId.thing;
const thing2 = form.childrenByPropertyId.thing2;
if (disabled) {
thing1.enable()
thing2.enable()
}
else {
thing1.disable()
thing2.disable()
}
disabled = !disabled;
})