1. Fabrik 3.9 has been released. If you have updated Joomla to 3.9, this is a required update.
    Dismiss Notice

Need to delete a specific group within a repeat group from a fireEvent

Discussion in 'Community' started by beatty_t, May 3, 2019.

  1. beatty_t

    beatty_t New Member

    Level: Community
    Hi All,

    What javascript would I use to delete a specific group within a repeat group from some other condition within a form?

    For example, I have a multi-select element (dropdown) where the selected options could change within a record (rowID). I want my repeat group to reflect the options selected in the multi-select element. If an option is selected, I am able to create a group using:

    Code (Javascript):
    var form = Fabrik.getBlock('form_' + formRef);
                var btn = form.form.getElement('#group' + groupId + ' .addGroup');
                    if (typeOf(btn) !== 'null') {
                    var e = new Event.Mock(btn, 'click');
                    form.duplicateGroup(e);
                    }
    Great!

    But, if a previously selected option is unselected (a group had been previously added and still exists), I need for the script to compare what is selected vs the groups that exist and where a specific group needs to be removed, I need the javascript function that can do that.

    Is there an equivalent to duplicateGroup(), that is called deleteGroup()? I think there is, but I need to know which parameters I need to include to target a specific group. I can't find the scripts that run when the delete icon is clicked to mimic that action.

    I am able to compare my list of groups and selected items to know which group needs to be deleted, but I don't know how to delete it!

    Thanks
     
  2. beatty_t

    beatty_t New Member

    Level: Community
    Hi All,

    Just wondering if this might be something simple that I've just missed somewhere in the help content that I could be pointed towards... I've been looking in the form.js file (/media/com_fabrik/js/form.js) and found the deleteGroup function. Now I'm just trying to figure out how I can use it to target a specific repeat group instance.

    Am hoping to get my mini-project that requires this completed within the next couple of weeks.

    Thanks


    Travis
     
    Last edited: Jun 10, 2019
  3. beatty_t

    beatty_t New Member

    Level: Community
    Friendly Bump...

    Can't figure this out...

    Thanks
     
  4. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    Here's an example of where our code "fakes" a deleteGroup button:

    https://github.com/Fabrik/fabrik/blob/master/media/com_fabrik/js/form.js#L1919

    Note that in this case, the code assumes there is only one repeat, so just grabs the first fabrikSubgroup from the #groupX (where X is the group ID) group container. You would need to find the correct fabrikSubgroup container for the one you want to delete.

    -- hugh
     
  5. beatty_t

    beatty_t New Member

    Level: Community
    Thank you so much!

    I was nosing around line 1961 and down... I missed the gem above it. I had gotten focused on deleteGroup: function(e, group, subGroup)....

    I'll try it out.

    Travis
     

Share This Page