Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Each time the page is loaded the StarBehavior duplicates the number of stars and a wrong rating value #10

Open
jcesarmm opened this issue Aug 31, 2017 · 3 comments

Comments

@jcesarmm
Copy link

I have a rating page and when it appears the first time I can see five values in the array with name "behaviors". However when the page dissapears and appears again the quantity of StarBehavior is duplicated each time I do this.

So, The rating sent by the control is 10,11,12..... (When the rating is between 0-5)

@BryanSoltis
Copy link

BryanSoltis commented Sep 19, 2017

I have the same issue. When I load with the rating initially. the rating values are correct (0-5). However, reloading the same page increases the rating values by the number of "new" selected stars. In looking at the behaviors collection, it is adding new behaviors to the list for the same group, resulting in 6+ behaviors.

@BryanSoltis
Copy link

After looking at it some, I added some math to correct the variation. Before the item.Rating is set, I do a loop to reduce by increments of 5 until it's the right range.

                while (position > 5)
                {
                    position = position - 5;
                }
                item.Rating = position;

After testing, this seems to resolve the issue.

@Nav1986
Copy link

Nav1986 commented Apr 21, 2019

@BryanSoltis , I tried your solution, but i could see that the controls will still be there if the rating is reseted.

I did following and it works.

StarBehavior.cs added following:
public static void ResetStarBinding() { starGroups = new Dictionary<string, List<StarBehavior>>(); }
Then before i load the page i call "StarBehavior.ResetStarBinding();"

This seems to resolve the problem and not adding more controls than there is needed, in my case 5 :)

I know this is old, but issue is still there, i wanted to share my solution with you all :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants