As we've seen in several chapters of this book, it's true, your jQuery plugin may require certain elements to be present in the DOM to transform content into a widget or interaction.
Here's the thing to remember: if HTML elements can be constructed to make the enhancement work at all, you can create those HTML elements, within the DOM, on the fly with jQuery. You don't have to force your client to create them in the editor!
Take a look at our work in Chapter 6, WordPress and jQuery's UI, with the UI plugin where we took simple, basic h3 headers and paragraphs and wrapped them dynamically in the proper markup for the jQueryUI tab widget. Or heck, even before that in Chapter 5, jQuery Animation with WordPress, where we took a client's unique post text (didn't have anything to do with HTML!) and were able to construct a lovely animated chart out of it.
jQuery is all about selectors and it's true, sometimes, to get started you need something clear and unique to select in the first place! Work with the site's editors when coming up with enhancements. It's much easier for most content editors to wrap their head around having to simply apply a unique category or tag to certain posts in order for the enhancement to take effect, or even manually adding in keywords to a post's header or formatting content in a specific way (like the chart example in Chapter 5, jQuery Installation within WordPress). Look at all of these options first, with a site's editor, to make sure the enhancement is really an enhancement, for everyone.
Was this article helpful?