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

beatty_t

New Member
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:

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
 
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:
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
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
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top