-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Gridster spawns new <style> block everytime widget added when "autogenerate_stylesheet" = true #211
Comments
Second. I'm working on dynamically added widgets and noticed this issue as well. I'm sticking with |
Using
This way gridster doesn't create another style tag for every widget but instead updates the contents of it. The drawback is that it changes all of the contents while ideally it should only add the necessary new rules. But I'm not smart enough to do that yet. It's also a bit faster. Here's a screenshot of chrome dev tools CPU profiler: It all works nicely, is faster and doesn't add lots of very similar style tags. But id attribute in style tag is very, very dirty. Please don't be harsh on me as I'm not at all a professional javascripter, am very very new to git and github. I hope someone can come up with a better solution. As for now this'll work for me. |
I implemented a similar patch. Btw "id" is a global attribute; you can use it on style and script tags (it even passes W3C validation). That's the only way you can make specific elements of those types selectable. |
@vieron would you be open to a PR on this? |
Joining the conversation... I stared playing with gridster this past week. I'm using it for an application I'm building in Microsoft.net! Happy Coding! |
Thanks this was helpful - solved the doubling up issue |
Hopefully fixes ducksboard#211 and ducksboard#294.
Worked fine for me !! Why this update is not add in the main repo ? Anyway, thank you !! |
* dasmall/gridster.js.git/master: Removing previously added style tags before adding new one. Hopefully fixes ducksboard#211 and ducksboard#294.
It would probably be better to clear the previous style block when adding a new one since the new one will always contain the CSS to style the new row/column + all the old ones.
Otherwise you get a stack of potentially unlimited style blocks as you add widgets to the page.
Let me know if you'll take a PR on this issue.
The text was updated successfully, but these errors were encountered: