[wp-trac] [WordPress Trac] #31964: Use a replaceable function for the beforeupload handler with shiny updates
WordPress Trac
noreply at wordpress.org
Wed Apr 15 14:29:08 UTC 2015
#31964: Use a replaceable function for the beforeupload handler with shiny updates
-----------------------------+---------------------------------------------
Reporter: DavidAnderson | Owner: jorbin
Type: enhancement | Status: reopened
Priority: low | Milestone: 4.2
Component: Upgrade/Install | Version: trunk
Severity: normal | Resolution:
Keywords: has-patch | Focuses: ui, javascript, administration
shiny-updates |
-----------------------------+---------------------------------------------
Comment (by DavidAnderson):
Thanks...
I'm in Firefox 37. So, looking at the gist - this differs from my test by
using .on() and .off(); I was instead replacing the value of
wp.updates.beforeunload and leaving the event handlers as they were.
Isn't that what accounts for the difference, rather than the enqueueing?
My live code, which works with my patch, was basically this:
{{{
var old_beforeunload_function = wp.updates.beforeunload;
// Over-write the default function
wp.updates.beforeunload = function() {
if (our_condition_fulfilled) { return old_beforeunload_function(); }
// Otherwise: let the unload proceed
};
}}}
So, I suppose I could instead do this, to make it work with the current
code:
{{{
jQuery( window ).off( 'beforeunload', wp.updates.beforeunload );
jQuery( window ).on( 'beforeunload', function(){
if (our_condition_fulfilled) { return wp.updates.beforeunload(); }
// Otherwise: let the unload proceed
});
}}}
Does that seem right?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/31964#comment:13>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list