WP admin – live post preview in iFrame
-
My goal is to show live preview in custom post type edit form in WordPress admin. I got to the point, where I can successfully display iframe with preview next to meta / ACF fields in post edit form as seen on this wireframe:
Image
https://i.stack.imgur.com/OrZaS.pngWhen I click on the “Preview Changes” button, iframe content is refreshed successfully. But I want to do it automatically after some of the ACF fields are changed. So I try to simulate clicking on this button with jQuery:
$('input, select', $('#acf-group_609ca87c411ae')).on('change', function() { $('a.preview').click(); });
But when I do this, the behaviour is completely different: instead of refreshing the iframe, the whole page is refreshed with the message: Post updated.
I feel I’m so close to making this live preview work but I’m stuck on this simple simulation of click for several hours. Could you help me?
EDIT: Forget the iframe thing – if you are wordpress programmer, simply open WP admin, on the edit post screen and try to simulate clicking on the “Preview changes” button programmatically. If you get the same behaviour as clicking on it – post me the javascript here. Thank you!
————————
code from wireframe design tool.
- The topic ‘WP admin – live post preview in iFrame’ is closed to new replies.