remi
remi copied to clipboard
css classes duplicates when using add_class
Hi Remi,
I usually use add_class() and remove_class() on Widget objects to style my objects depending on various events. However, when an action using add_class() is triggered multiple times, the class is added at each call, resulting in duplicates and preventing me from actually removing the class with remove_class() When using add_class, I would expect that the class is only added if it doesn't already exist to fix this, as corrected in the attached patch.
Regards, Francois
Hello @batzkass, why you don't simply call remove_class before each add_class? And however you can access the widget._classes array to manipulate directly
Hi Davide
It would simplify the developpers scripts with a single call. Anyway I added a function that do it, I just thought to others devs.
Le ven. 21 déc. 2018 à 11:24, Davide Rosa [email protected] a écrit :
Hello @batzkass https://github.com/batzkass, why you don't simply call remove_class before each add_class? And however you can access the widget._classes array to manipulate directly
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dddomodossola/remi/issues/259#issuecomment-449349801, or mute the thread https://github.com/notifications/unsubscribe-auth/ABhDwHEyYZ2pxYLFsGsWBZUqRsrzVh91ks5u7LbtgaJpZM4ZWOPZ .
@batzkass I thank you for the suggestion, I will make this change in the future ;-)
@batzkass, why not do everyone a favour and submit a pull request? ;)