• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

[Solved] Issue: Checkbox Javascript

aijosh

Member
Hello,

I have a bug on the checkbox javascript used to hide/show other elements on a form with repeatable group.

If the checkbox is clicked (inside the box itself) it works ok

But if the label is clicked it changes the behavior (show/hide) of the top record of the repeating group instead of the current record being clicked

Also, whatever had been chosen on the top record (show/hide) automatically becomes the behavior of the new repeats when you click the + button
 
What site template are you using?

It may not be significant, but some templates modify checkboxes and mess with their structure. So before I test this, just need to make sure I check with the right framework.

-- hugh
 
Please note that the file being called is the minified file so I could say this did not work. You'll have to make changes to the .min file too.

Secondly,
Also, whatever had been chosen on the top record (show/hide) automatically becomes the behavior of the new repeats when you click the + button
This is still persistent.

If the elements are hidden for the base ID, any new repeat created remains hidden and if the elements are visible every new repeat created is visible.

I want the repeats to get created with the default hide/show settings
 
Ah, yes ... I had minified it, just hadn't included that in the push. It's up now.

Do you have 'load' events on your checkbox? To reset the show/hide state to default, you have to handle it with load events and defaults.

When a group is duplicated, we run all the load events for its elements. Also, unless you've specified 'copy values' in the group settings, we revert each element in the new group to the default value.

So, for example, in my test setup for this, I have a checkbox with values 1 and 2, two 'click' events that show another element if 1, and hide it if 2, and two 'load' events that show it if 1 and hides it if 2. The '1' checkbox value is set as the default.

So if I set the first repeat to 2, it hides the other element. I add a new group, it copies that first repeat, resets the elements to defaults, the load event runs for the checkbox, and shows the other other element.

-- hugh
 
Do you have 'load' events on your checkbox? To reset the show/hide state to default, you have to handle it with load events and defaults.
Yes. https://www.dropbox.com/s/nztbg3ohkfr5yhe/rrrr.png?dl=0

When a group is duplicated, we run all the load events for its elements. Also, unless you've specified 'copy values' in the group settings, we revert each element in the new group to the default value.
No. I didn't set copy values to yes. I checked again to be extra sure and its still on No
 
Hmm, could be a couple of things. Try this:

https://github.com/Fabrik/fabrik/commit/52e61e50a8724c72fa231be2d681cf42a092eb4c

... which moves where we reset the element values to defaults to earlier in the processing ... plus I think you'll need to add load events to show the elements if they are hidden. It looks like currently you only have load events for hiding if the checkbox is checked, but you don't have load events for showing it if the checkbox isn't checked. Which you wouldn't usually need, but will need in this scenario, with adding repeat groups.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top