As far back as 1.0, jQuery has provided a trigger function that allows us to:
Execute all handlers and behaviors attached to the matched elements for the given event type.
But it wasn’t until 1.3 that this particular function became significantly more useful, at least as far as I’m concerned. I say that because that’s when we gained the ability to define custom events and then set handlers for them.
What, though, is a likely use case in which custom jQuery events are useful in the context of WordPress? Off the top of your head, you may be able to come up with many. Or maybe not.
It hasn’t been until lately that I’ve been using them significantly more than usual. So I thought I’d share how I’m using them if for now other reason than showing you how to wire them up to your work.
When building WordPress plugins for myself or others, several of the things I take into account – as we all should – is the level of maintainability, scalability, and support for the plugin as WordPress continues to move forward.
As the support for ES6 continues to rise, jQuery continues to move forward with development, and the desire to use new APIs to build out our solutions, I believe it’s worth asking the question:
Do we really need to stick with jQuery?
In my experience, most browser extension overlays use a background with the type of data:image/svg+xml. Furthermore, each of these overlays uses inline styles (rather than external stylesheets) to render their buttons (or whatever controls they are opting to render).
But first, why would we care even to hide them?
One of the challenges of learning a library (be it the standard library of functions that come with a programming language or a third-party project) is two-fold:
- learning the functions that are available,
- learning how to use said functions.
And, really, sometimes even learning how to use said functions isn’t all that hard – it’s knowing when to use a given function to help minimize code while still achieving the goals of the project.
There’s some programmer joke that says there are two things hard in computer science: naming things and time zones. On second thought, maybe that’s not the joke at all (because it sounds too true to be funny).
Specifically, I’m talking about Timedropper. It’s a cool jQuery time plugin designed to make it easy for you to implement options into your web application that gives users an intuitive way to work with time.