I’m forever grateful to all the much more talented people than me who choose to spend some of their free time by uploading useful stuff onto the web. A good example is the jQuery Plugin collection in general and the imgpreview plugin by James (Jimmy ?) Padolsey in particular.
Thank-you guys. A special thanks to Jimmy.
There’s only one problem with all of this: all these plugins allow relatively inexperienced coders like me to try and do stuff. I’ve been coding since I was a boy, but haven’t been paid to write code since I became a manager 11 years ago. I like to dabble with coding projects in my free time and I hate to read manuals, and together this isn’t a good combination. My only comfort is I know there are a lot of us out there who hate to RTFM.
Which leads me to a frustrating afternoon spent trying to implement the imgpreview plugin. I applied to my little project and kept getting some utterly unintelligible error messages (so a is undefined, now what?). I tried the usual (Google – 1 hit with no answer), dug up a non-minified version of the plugin (error messages said it couldn’t find the block I was pointing it at) and downgrading my copy of jQuery to 1.3.1 (still no results), I decided to go back to basics and implement a simplified version of Jimmy’s demo. Aaaand still, no dice.
By this point I knew I was doing something really, really dumb. As anyone who has programmed for more than a few years knows, there are only two paths to true enlightenment and I switched from random to methodical trial-and-error to find my problem: I had to declare the jscript after my block, not before.