1. Fabrik 3.9 has been released. If you have updated Joomla to 3.9, this is a required update.
    Dismiss Notice
  2. If you update to Joomla 3.9.16, you will have to update Fabrik from the latest GitHub version, to fix a bug introduced in Joomla, which makes it impossible to list front end folder locations in backend JForms. This affects things like template selection.
    Dismiss Notice

Show/hide Group

Discussion in 'Standard Support' started by Incremental, Nov 21, 2013.

Thread Status:
Not open for further replies.
  1. Incremental

    Incremental Member

    Level: Community
    Hi,
    I know that there are many posts about the subject, and some informations in the Wiki, but I need some explanations on the new templates.
    I just would like to have a simple AJAX Form used by Admin to reply to a Contact Form
    This Admin Form has 2 Groups (Contact, Reply) and should behave like this :
    • by default only the Contact Group is showed (user contact information) WITH a 'Reply' toggle button.
    • clicking on the 'Reply' toggle button should make appear/dissapear the 2nd Group : Reply which contain answer fields and a button to send answer email
    Could you put me on the way for that ?
    Thanks by advance.
     
  2. Incremental

    Incremental Member

    Level: Community
  3. rob

    rob Administrator Staff Member

    Level: Community
  4. Incremental

    Incremental Member

    Level: Community
    Sounds simple !
    1) could you explain code in
    http://fabrikar.com/forums/index.php?wiki/accordion-form-groups/
    which should do the job ? and tell me why it's not working ?

    2) I finally added 2 JS events on my Element button 'Fill Reply fields'
    • onload hide is working
    • onclick : I get a problem !
      if I use a predefined action show, it's working also, but one shot (normal)
      but what about toggle ??? I only see 'slide toggle' which doesn't work.
    • With Firebug, I see also the following error :
      TypeError: btn is undefined data[btn.name] = btn.value;
      when clicking on the button.
      AND I get a never ending 'Loading' spinner.
    I would only have this button to show/hide Reply Group, but it looks like if it is submitting something...

    3) Don't know if the toggle should be programmed in JS, but I also tried to use raw JS
    Code (Text):
    document.id('group6').show();
    or
    document.id('group6').hide();
    without success. What could be wrong with this syntax ?

    PS : you can see it clicking on both EDIT and 'R?pondre JS' buttons
     
  5. rob

    rob Administrator Staff Member

    Level: Community
    1 - I'm presuming you are refering to this page: index.php/fabrik/reply ? The code listed in the wik might well simply be for fabrik 3.0 - in any case its not what you need for this situation. That code toggles groups based on clicking on the group legend, not appropriate if you want to show / hide a group from a button click.

    2 - Ahhh cough cough - looks like the button click event will also attempt to submit the form. I've fixed that in this commit: https://github.com/Fabrik/fabrik/commit/622a7d1d0842cd2471a5559f8718b26f66bc7d03

    3 - doesn't look to be anything wrong with that js - the problem is probably the same issue as #2.
     
  6. Incremental

    Incremental Member

    Level: Community
    Thanks Rob,
    but what about the missing Toggle Event in the Javascript plugin ?
    It's exactly what I need and don't know how to do it !
     
  7. rob

    rob Administrator Staff Member

    Level: Community
    not quiet sure what you meant there? There's the built in "slide toggle" fx which should work, (I've just fixed a small ish bug where it wasn't working if multiple fx's were applied to the same group)
    To get it to work you basically set the condition options to always return true, as the toggle has to happen regardless of the element's value.
     
  8. Incremental

    Incremental Member

    Level: Community
    Sorry Rob,
    it wasn't obvious that slide in/out/toggle was the same to hide/show
    In fact, hide/show are working,
    but slides and especially toggle don't do anything.
    What could be wrong ?
    Capture.PNG
     
  9. Incremental

    Incremental Member

    Level: Community
    Friendly bump ;)
     
  10. rob

    rob Administrator Staff Member

    Level: Community
    you've got two conflicting effects on the same group? Not at all sure what you want to do there, but I would remove the "hide group reply" one and just use the toggle one.
     
  11. Incremental

    Incremental Member

    Level: Community
    Rob,
    I unpublished the on load JS plugin and set the other one to "Slide toggle", but nothing happens.
    (the onLoad hide was working)

    I just want to load the form with Reply group hidden and if I click on the button Reply toggle appear On & Off of Reply group.
     
  12. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    What Rob meant by "conflicting effects" is that you need to use the same effect to show / hide. So if you slide a group to hide it, you have to slide it to show it. If you use a simple hide, use a simple show.

    Anyway, looking at this now. And it looks like there may be an issue with FX, as the hide/show on change test in my FX test form has quit working.

    -- hugh
     
  13. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    OK, that was a different issue ... ignore that one ...

    The problem seems to be that you can't mix a slide in/out with a slide toggle. Not a Fabrik thing, seems to be a Mootools FX.Slide thing.

    I'm still looking, to see if there's some way of getting this to work. But it looks like with Moo's FX, you can either hide/show specifically, or you can toggle, but you can't do both.

    -- hugh
     
  14. Incremental

    Incremental Member

    Level: Community
    Cheesegrits,
    I discovered that (from the frontend) :
    • in admin part : menu Fabrik / List Contacts / click on Edit
      the "Show reply Fields" button has no effects
    • in public form "Nous Contacter" the "Show reply Fields" button (who should be not visible according to my ACL) is perfectly working on the Reply group (who should be not visible according to my ACL)
    Hope this could be a clue.
    Thanks for help
     
  15. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
  16. Sophist

    Sophist Well-Known Member

    Level: Community
    Hugh - incremental asked me to look at this also, and I have just tweaked it. Button was not working because he was getting a JS error on a date element (from memory a get method wasn't working) - when I unpublished the date element, the JS started working.
     
  17. Sophist

    Sophist Well-Known Member

    Level: Community
    Oops, Hugh just said that!!!

    However, if you set the group display to "Yes, but hidden on load" you get a "display:none" on the group fieldset. Using a show JS action on this when you click the button doesn't work - because the fx for show reverses the effect of an fx hide and fx hide doesn't work the same way I guess. So you have to have an on-load event to hide the group so you can show it when the button is clicked. Pity.
     
  18. Incremental

    Incremental Member

    Level: Community
    Updated Github and disabled On Load event : Toggle is perfectly working.
    I was confused by the On Load event, as I want to hide the Group when the Form is loaded.
    • It would be fine to change the label "Event" to "Element event"
    • Is it possible to add a Form load event ?
      or do you have a clue to implement it without a custom JS to put in components/com_fabrik/plugins/form/fabrikjs/scripts ?

    PS : Wiki Javascript form plugin http://fabrikar.com/forums/index.php?wiki/javascript-form-plugin/
    Link is broken for Fabrik 3 particularities.
     
  19. Sophist

    Sophist Well-Known Member

    Level: Community
    I have fixed the link (hopefully to the correct page).
     
  20. Incremental

    Incremental Member

    Level: Community
    Thanks for the wiki !

    If this can help others, the solution found by Sophist is :


    • On Load : When element "ReplyButton" is shown, slide toggle group "Reply"
    • On Click : When element "ReplyButton" is shown, slide toggle group "Reply"
     
Thread Status:
Not open for further replies.

Share This Page