1. Fabrik 3.8.1 has been released. It is mostly bug fixes and feature enhancements, but does include two new plugins (push notifications, and the sequence element). As usual we strongly recommend testing the new release on a sandbox if your application is mission critical, and always do an Akeeba backup before updating.
    Dismiss Notice

[Solved] Issue: Checkbox Javascript

Discussion in 'Standard Support' started by aijosh, Jul 14, 2018.

  1. aijosh

    aijosh Member

    Level: Standard
    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
     
  2. aijosh

    aijosh Member

    Level: Standard
    Hello, any update on this?
     
  3. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    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
     
  4. aijosh

    aijosh Member

    Level: Standard
  5. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
  6. aijosh

    aijosh Member

    Level: Standard
    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,
    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
     
  7. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    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
     
  8. aijosh

    aijosh Member

    Level: Standard
    Yes. https://www.dropbox.com/s/nztbg3ohkfr5yhe/rrrr.png?dl=0

    No. I didn't set copy values to yes. I checked again to be extra sure and its still on No
     
  9. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    Can you point me at the page?

    -- hugh
     
  10. aijosh

    aijosh Member

    Level: Standard
    Login with the ijaikr frontend user and visit url/profile/career
     
  11. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    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
     
  12. aijosh

    aijosh Member

    Level: Standard
    This solved the issue.

    Thanks
     

Share This Page