jaredatch/Custom-Metaboxes-and-Fields-for-WordPress — Issue #79: Avoid live() and alias event function names in scripts, namespace events
Author: GaryJones
Created: 2011-12-31 18:22:06+00:00
State: open

There are currently two calls to `.live()` in the CMB scripts. WP 3.3 comes with jQuery 1.7.1, and as of jQuery 1.7, the `.live()` method is deprecated. The `.on()` function should be used instead (not quite a straight function rename swap).

Similarly there is one occurrence of a `.change()` function. This too should be swapped to using `.on()`.

There's a couple of benefits of using `.on()` and not just to avoid using deprecated functions:

1) The event names can be namespaced, with multiple namespaces. This allows other code to interact with CMB code, without affecting existing WP code. For instance, it can unattach a `click.cmb` event from an element, without removing any other `click` events from the same element.

2) Since the `.bind()` and `.delegate()` functions are also deprecated, using `.on()` instead of `.change()`, `.click()`, `.hover()`, `.keypress()` and all the other shortcuts makes it far easier to search through code to find where functions are attached to elements since there's only one string to search for.