In Part One, I discussed managing the scope of
$(document).ready(). Next comes the challenge of organizing the contents of
$(document).ready() to balance efficiency and maintainability. My team accomplishes this by taking advantage of the Array behaviors of jQuery to structure our code so that function dictates form. Put into practice, these behaviors will structurally organizing the code without imposing rules and processes—because we all know just how effective rules and processes are.
Welcome to the new and improved Braindonor Network. As you can see, I have completely updated the WordPress theme of this site. There are still some rough edges—but I liked the new theme so much that I was not willing to wait until everything was completely polished. The new theme is a combination of the barebones Sandbox theme and Twitter’s Bootstrap.
I’ve been asked by a large number of developers if I know any solid jQuery best practices. The answer is a huge YES! I’m also getting around to changing my answer to their immediate follow-up. Do you have them written down so you can share them with me? In an effort to change my answer to another huge YES, I am starting a series on jQuery Best Practices that will continue until I run out of steam. The first best practice that I have to share is how to properly manage the scope of your jQuery scripts.
A common component of many of the websites that I build are small administrative areas where clients are able to perform tasks such as downloading leads or scheduling appointments. Until recently, most of those websites were built to run on top of a content management framework–with the CMS providing most of the back-end interface that I deliver. I started using Twitter’s Bootstrap framework to deliver a consisten look and feel with our ASP.NET MVC3 applications. Bootstrap provided me with a clean CSS grid system, clean controls, and a host of other components. The biggest disconnect between Bootstrap and MVC3 is the unobtrusive validation.
With my latest gig sending me back into the .NET world, I have been busy migrating quite a few of my tools and experience to play nice with ASP.NET sites. One of my favorite open-source tools that is gaining popularity in .NET is jQuery. For several years now, I have been using jQuery heavily to provide rich interaction on websites. When faced with the basic UpdatePanel in ASP.NET, I was presented with a challenge. I wanted a solution that would automatically call jQuery so that new content was properly parsed and updated. Because I had been managing all the AJAX calls in my other development, this was trivially easy to do. UpdatePanel hides all of this inside the ASP AJAX libraries and scripts—making it difficult to figure out where and how to structure my jQuery code. After some research and experimentation, I have a solution up and running on multiple sites now that integrates everything in a very clean manner.
I have a friend that wants to update a banner on his WordPress blog homepage without changing the template files. I tell him I’d be glad to help him out and start working on a plugin that provides a custom administration page to allow for this. As I am a firm believer in the power of a lazy coder to get things done faster and better, my first thought was: “Why don’t I just see if I can hijack the ‘Select Image From Gallery’ page to do this?” that process for my own ends shouldn’t take me but a few minutes…and a lot less time than trying to build my own media selector. Like nearly all the content on my site, if you are reading this, I wasn’t able to find my answer elsewhere.