Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialRobert Richey
Courses Plus Student 16,352 PointsjQuery UI Theme Selector
Hi Everyone,
I figured this might be worth sharing, for anyone who's ever been interested in changing themes on-the-fly for a page.
What drove this demo was a desire to change themes with a simple menu selection. That led me down the path of trying to mess around with document.styleSheets
, or other voodoo techniques; but, it turns out, it's a rather simple process to load an AJAX response into a style tag before the main content (at the top of body
or bottom of head
).
It's worth mentioning that I was unable to get jQuery icons to work - they don't like being AJAX'ed in, apparently. So, I'm using Font Awesome icons for each theme change - just the left and right arrows on the calendar.
If you have any questions or feedback, please feel free to post it below. I enjoy the interaction.
All the best,
Robert
1 Answer
Justin Iezzi
18,199 PointsVery cool, favorited it! I've wondered before how this was done, this is a great example to learn from.
Super tiny nitpick -
.ui-datepicker-next,
.ui-datepicker-prev {
cursor: pointer;
}
*Edited for a little better coverage over the buttons. Thanks for sharing!
Robert Richey
Courses Plus Student 16,352 PointsRobert Richey
Courses Plus Student 16,352 PointsHey Justin,
Glad you liked it! I'm really bummed that I can't figure out a way to access the icons, so I scrapped them and cleaned up the code. Also, I went ahead and tested it locally, spinning up a server. By doing this, I can access the icons and it looks great.
Justin Iezzi
18,199 PointsJustin Iezzi
18,199 PointsIf it works on an actual server environment over codepen, then that sounds like a proper solution to me. Glad you got it working!