Skip to content
This repository was archived by the owner on Jul 12, 2019. It is now read-only.
This repository was archived by the owner on Jul 12, 2019. It is now read-only.

Add triggering of events on show and hide  #20

Description

@landwire

Hi there again,
I find it useful if some events would be triggered on the element on hiding and on showing. I am dealing with some validation and required fields (inside hidden sections) on the FE and BE side. So I need to toggle the required attribute depending if the section is shown or not.

I do not know how to do a PR, but this is basically what I would want/need:

$.fn.showOrHide = function(is_met, $section) {
        console.log('is_met', is_met);
      if (is_met) {
        $section.slideDown();
        $section.trigger('sectionvisible');
      }
      else {
        $section.slideUp();
        $section.find('select, input').each(function(){
            if ( ($(this).attr('type')==='radio') || ($(this).attr('type')==='checkbox') ) {
                $(this).prop('checked', false).trigger('change');
            }
            else{
                $(this).val('').trigger('change');
            }
        });
        $section.trigger('sectionhidden');
      }
    };

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions