Previously unchecked check box becomes checked again when applying changes

Yoyo Bubble asked on March 4, 2019 21:18

Good day DevNet!

I'm having an interesting issue with a custom webpart I've built.

I've created a "video carousel" widget that allows users to add up to 8 videos via checkboxes and also gives them the ability to make any of those videos a featured video with another checkbox. To do this, I have the videos repeated in two places in the markup and based on whether the featured checkbox is checked will decide if the video is displayed in the featured div vs the sidebar div.

I also needed to prevent the featured checkbox from being checked if it is already checked for another video. I have set enable conditions on all the featured checkbox fields so if all the other featured checkboxes are unchecked, this becomes enabled. This is what I'm setting for the Video One Featured field: VidTwoFeatured.Value==false && VidThreeFeatured.Value==false && VidFourFeatured.Value==false && VidFiveFeatured.Value==false && VidSixFeatured.Value==false && VidSevenFeatured.Value==false && VidEightFeatured.Value==false;

Here's my issue: When you're editing the widget on the page and you check the featured box for one of the videos and save - boom. works as intended.

The problem is that if I go back to edit it once more, uncheck the featured checkbox for the currently featured video (because you need to uncheck it in order to enable the other ones) and then check the featured checkbox for ANOTHER video - After I hit "Apply", the last featured checkbox that was checked becomes checked again as well as the one we intended to check - so now both videos are featured which then disables the featured checkboxes for both.

Not sure how or why this is happening. I've tried rewriting the enable conditions several times. Has anyone experienced this before? Any ideas on what to check for or how to fix? Any help is greatly appreciated! If anything needs clarified, I'm happy to do so.

Here's a GIF demonstrating the problem: Image Text

Recent Answers

Sir McShneebles answered on March 4, 2019 21:35 (last edited on March 5, 2019 12:27)

Hello Good Sir,

Have you tried making your webpart properties required, and/or setting them to have a default value? Perhaps the problem lies within the inner workings of your webpart's enabled conditions, which could be simplified by only allowing the item to be enabled if any others have a value.



Sir McShneebles

1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.