Discussion:
Stay/Leave Message on Save
Brian Hogg
2014-05-21 13:39:56 UTC
Permalink
Hi all,

I built in extra fields / meta boxes in the admin panel as part of a theme, and added extra submit buttons so users didn’t have to scroll all the way up to click Publish/Save. Since WP 3.9 there’s now a "stay/leave” popup appearing when the extra submit buttons are used and the description/title has been changed.

I’ve searched around the js a bit and am not seeing where the window.onbeforeunload function is being set, and setting window.onbeforeunload = null; when the extra submit buttons are clicked has no effect. The post does still save when “Leave this page” is selected in the popup. Is there another way to hook in and disable this stay/leave message?

Thanks!
Brian

---
brianhogg.com
905.966.1778
Nikola Nikolov
2014-05-21 13:52:30 UTC
Permalink
Hi Brian,

What about hooking a callback to your buttons "click" event and just
triggering a "click" on the WP Save button? That should do the trick in my
opinion, but I haven't tested it.
Post by Brian Hogg
Hi all,
I built in extra fields / meta boxes in the admin panel as part of a
theme, and added extra submit buttons so users didn’t have to scroll all
the way up to click Publish/Save. Since WP 3.9 there’s now a "stay/leave”
popup appearing when the extra submit buttons are used and the
description/title has been changed.
I’ve searched around the js a bit and am not seeing where the
window.onbeforeunload function is being set, and setting
window.onbeforeunload = null; when the extra submit buttons are clicked has
no effect. The post does still save when “Leave this page” is selected in
the popup. Is there another way to hook in and disable this stay/leave
message?
Thanks!
Brian
---
brianhogg.com
905.966.1778
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
Brian Hogg
2014-05-21 14:26:38 UTC
Permalink
Hi Nikola,

Yeah, I think a jQuery('#publish').click() will do the trick. There's some logic based on the button clicked (which is passed in POST), but I should be able to fake that by injecting a hidden input.

Thanks!
Brian


----
brianhogg.com
905-966-1778
Post by Nikola Nikolov
Hi Brian,
What about hooking a callback to your buttons "click" event and just
triggering a "click" on the WP Save button? That should do the trick in my
opinion, but I haven't tested it.
Post by Brian Hogg
Hi all,
I built in extra fields / meta boxes in the admin panel as part of a
theme, and added extra submit buttons so users didn’t have to scroll all
the way up to click Publish/Save. Since WP 3.9 there’s now a "stay/leave”
popup appearing when the extra submit buttons are used and the
description/title has been changed.
I’ve searched around the js a bit and am not seeing where the
window.onbeforeunload function is being set, and setting
window.onbeforeunload = null; when the extra submit buttons are clicked has
no effect. The post does still save when “Leave this page” is selected in
the popup. Is there another way to hook in and disable this stay/leave
message?
Thanks!
Brian
---
brianhogg.com
905.966.1778
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
Nikola Nikolov
2014-05-21 15:05:59 UTC
Permalink
In theory it should work. I do remember the logic you're mentioning(I've
seen it before when I was going through core), but I can't remember exactly
where it's located...

Well - give it a try and see if it fixes the problem, if it doesn't we'll
give it another try.

Nikola
Post by Brian Hogg
Hi Nikola,
Yeah, I think a jQuery('#publish').click() will do the trick. There's some
logic based on the button clicked (which is passed in POST), but I should
be able to fake that by injecting a hidden input.
Thanks!
Brian
----
brianhogg.com
905-966-1778
Post by Nikola Nikolov
Hi Brian,
What about hooking a callback to your buttons "click" event and just
triggering a "click" on the WP Save button? That should do the trick in
my
Post by Nikola Nikolov
opinion, but I haven't tested it.
Post by Brian Hogg
Hi all,
I built in extra fields / meta boxes in the admin panel as part of a
theme, and added extra submit buttons so users didn’t have to scroll all
the way up to click Publish/Save. Since WP 3.9 there’s now a
"stay/leave”
Post by Nikola Nikolov
Post by Brian Hogg
popup appearing when the extra submit buttons are used and the
description/title has been changed.
I’ve searched around the js a bit and am not seeing where the
window.onbeforeunload function is being set, and setting
window.onbeforeunload = null; when the extra submit buttons are clicked
has
Post by Nikola Nikolov
Post by Brian Hogg
no effect. The post does still save when “Leave this page” is selected
in
Post by Nikola Nikolov
Post by Brian Hogg
the popup. Is there another way to hook in and disable this stay/leave
message?
Thanks!
Brian
---
brianhogg.com
905.966.1778
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
Loading...