Repeat Group SubGroup Index

Status
Not open for further replies.

startpoint

Active Member
Hi,
I create repeat group with two elements: yesno and field. I want when click on 'No' field element to be disabled, when click 'Yes' field element to be enabled for enter data.
I use this code in my form_X.js file:
JavaScript:
jQuery("#group50").bind("change click", function(event) {
    jQuery(".fabrikSubGroup").each(function(i) {
        jQuery('#___radio_'+ i + ' input').on('click', function() {
            console.log(i);
            sel = jQuery(this).val();
            if(sel == 0){
                jQuery("#___element1_"+ i +"").prop('disabled',true);
            }
            if(sel == 1){
                jQuery("#___element1_"+ i +"").prop('disabled',false);
            }
        });
    });
});

but I have problems when add or delete rows in this group.
Problems can be seen on video:
http://screencast.com/t/gO1yftO3v

How to change code to work properly?

Regards
 
Thank you for this integration.
But the problem exists again in repeated group.
When initially adding row no problem. But even when you delete a row, indexing them wrong.

Regards
 
Works for me ...

http://screencast.com/t/AErc1HytO

Although I did add a little tweak in this commit:

https://github.com/Fabrik/fabrik/commit/117dcb070974218d719c44b4bd6fd10f6c84df17

... to run load events when duplicating a group, and I added a load event to enable on load if my 'disable' element == 0. Without that, because the enable/disable sets an attribute on the input, and we clone the DOM structure from a clicked group, it would retain the state of the group it was cloned from.

Can you give me some more detail on "indexing them wrong"?

Note that indexes are changed when you delete. We retain sequential indexing. So if you delete a group, the following ones will be re-indexed to shuffle the indexes downwards. But the built in FX should handle that - as you can see from that screencast.

-- hugh
 
I finally found already when it gets problem: when adding a new order no problems. In slow deletion line by line also no problem.
But as quickly delete rows problem occurs.
Example: if there are 5 rows and press the delete button 5 or more times, fail to remove rows from html and the problem appears.
Tested with Chrome and Firefox.

http://screencast.com/t/yCDMgzm6Y7U

Try in this way.

Regards
 
Hmm. Yeah, I can see why that would happen. I think the only workaround for that is going to be to disable all the +/- buttons when one is clicked, until the group duplication or deletion is complete.

What must be happening is that if two deletions are running at the same time, the first one will start shuffling the group and element names and ids down (so if you delete #2, 5 becomes 4, 4 becomes 3, 3 becomes 2). Meanwhile the other deletion (say #3) runs, tries to delete itself, thinking it is #3, but by the time it runs, it has had its repeat count changed to 2.

I'll look at that tomorrow,

Hugh


Sent from my Nexus 7 using Tapatalk
 
Sorry, but the problem exists when delete row quickly.
Then some rows not deleted and enable/disable function not work properly.

Regards
 
I don't seem to be able to replicate that. Which site / form is this on? It'd help if I could get my hands on it.

-- hugh
 
Nope, I can't get it to mess up. Maybe it's because I'm on a laptop with a trackpad, so there's a limit to how fast I can do things. Next time I'm on my server, I'll give it a go there. I would do it now, but that'd mean standing up and moving to the other side of the room ... and I have a large dog asleep on my legs. And you know what they say about letting sleeping dogs lay.

-- hugh
 
The dog finally woke up, so I'll go take a look. I need more coffee anyway, so standing up is a requirement.

(Although my recent back surgery has improved things dramatically, standing up is still something I tend to plan in advance).

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

Thank you.

Members online

Back
Top