[wp-trac] [WordPress Trac] #18590: Swap out "return false" JS calls for preventDefault
WordPress Trac
wp-trac at lists.automattic.com
Tue Sep 6 10:35:00 UTC 2011
#18590: Swap out "return false" JS calls for preventDefault
----------------------------+------------------------------
Reporter: Viper007Bond | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Administration | Version: 3.3
Severity: normal | Resolution:
Keywords: needs-patch |
----------------------------+------------------------------
Comment (by sanchothefat):
@Viper have you tried using jQuery's namespaced event bindings?
My approach for hooking onto elements with a click handler attached is to
use the syntax described here [http://docs.jquery.com/Namespaced_Events]
For example you would use:
{{{
$( '#foo' ).live( 'click.myplugin', function() { ... } );
}}}
Essentially this approach sandboxes your plugin code from the default
code. There is a big advantage to this in that it means that people can
unbind and rebind specific handlers - useful for plugin/theme authors who
need a little extra control or a different behaviour. Think of it as the
action/filter API but for jquery events. In some cases I unbind the
standard wordpress click handler and add some of my own code before it eg.
for pre-processing some data before widgets are saved.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/18590#comment:6>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list