For running J!5.1 you must https://fabrikar.com/forums/index.php?wiki/update-from-github/ or include the new file manually https://fabrikar.com/forums/index.php?threads/joomla-5-1-and-fabrik-cannot-find-files-error.54473/post-285151 See also Announcements
Please see our announcement here.
requirejs(['fab/fabrik'], function () {
var form = Fabrik.getBlock('form_1', false, function (block) {
// Create an array of the fields we want to show hide, these are the full element names
var fieldNames = ['element_test___list', 'element_test___test'];
var fields = [];
for (var i = 0; i < fieldNames.length; i ++) {
fields.push(block.elements.get(fieldNames[i]));
}
// This is the radio button which we will toggle on (i'm presuming a value of 0 hides the fields and a value of 1 shows the fields)
var rad = block.elements.get('element_test___rad');
// It could be that the radio buttons default state means we need to hide the fields.
if (rad.get('value') == 0) {
toggle(fields, false);
}
// Add a click event to the radio buttons to toggle the show/hide state.
rad.addEvent('click', function () {
state = rad.get('value') == 0 ? false : true;
toggle(fields, state);
});
});
});
// Our toggle function
var toggle = function (fields, show) {
for (var i = 0; i < fields.length; i ++) {
if (show) {
fields[i].show();
} else {
fields[i].hide();
}
}
}