Repeat Group SubGroup Index

Status
Not open for further replies.
Can you point me at your page? I don't seem to be able to get it to fail no matter how fast I try and click the + or - buttons.

-- hugh
 
Oh yeah, duh, sorry, you did say. Been a long day. Well, week. Year. Couple of years. OK, lifetime.

Looking now.

-- hugh
 
OK, I can duplicate it on your site with a mouse. But I really have no clue what's happening. In theory that gate I put in there should prevent that. But the problem is, JS being asynchronous and event driven, it's possible there's some events kicking off inside the group duplication code which aren't completing in time. And debugging it is really hard, because anything to do with timing issues in events is a "Heisenbug", the very act of observing / debugging it, changes it.

Not really a lot I can do about this, without some serious refactoring. I'll try and think of a bandaid I can put on it, but offhand I can't think of anything.

-- hugh
 
I hope you manage to find the right solution.
Unfortunately, the problem I think is obtained when calculated in the fields in repeating groups.

Good luck and I am ready to test.

Regards
 
I'm not likely to come up with a fix any time soon. This is one of those corner case issues which requires a disproportionate amount of time to fix, as it only affects ... well, you, as far as I can tell. I've never run across this before, and it is code which has been out there for a long time. I guess people just don't click those buttons very quickly. The vast majority of people just delete or add one at a time, or are slower than you.

This is actually becoming a tough issue for us in general. As the code matures, and we've fixed most of the simpler issues, the ones that remain are increasingly ones like this - corner case, only affecting small numbers of people, difficult and time consuming to fix. And that simply just doesn't mix well with an "all you can eat", low cost subscription support model. I've already spent about four hours on this, which means even if you didn't need any other support this month, we're already down to about $5/hour, split two ways. I could earn about four times that wearing a paper hat and asking people if they want fries with that. Wouldn't be as much fun, but at least I'd be able to eat. :)

That said, I have one idea left which won't take too long to test. But if that doesn't work, it's going to be "it is what it is" unless someone is prepared to fund the time to work on it.

-- hugh
 
I hope to succeed with the latest idea.
I think it is important issue when using a repeating groups.
I appreciated and continue to appreciate the time you spend to solve this and any other problems, but also support you for the realization of our ideas.

Regards
 
OK, try this:

https://github.com/Fabrik/fabrik/commit/cd1e0664643fbffb693dd93645310f2b1376c857

I've added debouncing to the click events, which should prevent any add/remove events closer together than 500ms from happening. Although I would have thought the gating I added would have fixed it, so not sure if this will help, but it's worth a try.

If this doesn't work, I'm not going to be able to do any more work on this without getting some funding. If it was an issue affecting everyone, I could justify more hours on it, but as it seems to be a very rare issue, and I've now put 6 hours into it, I'm past the point of diminishing returns.

-- hugh
 
Thank You, Hugh for this work.
I think that this is a good solution.
By the way I did pay for a monthly subscription.

Regards
 
Yup, sorry, I wasn't saying you didn't have a sub. Just that some issues take too long for me to be able to fix them on a support subscription basis.

Have you tested the new code?

-- hugh
 
Yes.
I am glad that you managed to find a good solution.
Finally to finish with index of repeating groups: if I create following function:
PHP:
function repeat_group(el) {
    //id = el.element.id;
    val = el.getValue();
    //console.log(val);
    var rnum = el.getRepeatNum();
}
and run it for example from dropdown element with repeat_group(this), then var rnum is the index of this group where I start function.

How to do that if I run the function from my form_X.js file to get index value on given repeated group?
If you know how to define and use el in file then the function will work.

Regards
 
Last edited:
Well, it depends on what you code is doing. If you are (say) using a jQuery("some selector").on('click', function(e) {...}), then you can do it by using the target id to get the element object, something like ...

Code:
el = Fabrik.getBlock('form_X').formElements.get(e.target.id);
var rnum = el.getRepeatNum();

You can also use el.options.repeatCounter, which I think may be slightly more reliable. I think getRepeatNum() does it by just regex'ing out the _X on the end of the ID, whereas options.repeatCounter is set in the group duplication code. So getRepeatNum() could be wrong, if you happen to run your code in the middle of a duplication.

-- hugh
 
Thank you, Hugh!
This information helped me a lot.
Thanks for your time and patience.
I think all that done, it will be useful to other users.

Regards
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top