最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

block editor - How can I check if a post is dirty using javascript on the edit post screen?

programmeradmin5浏览0评论

I'm trying to block a custom javascript function from running (with an appropriate error, of course) if the current post is dirty (ie, something has changed either in the editor or a custom field). I can't seem to find the variable or function that the editor page uses to determine this.

Edit for further information: I've added an ACF block in the sidebar, on the Edit page of a custom post type, that has several buttons that have onclick events to run a JS function. That much is working properly as it is.

The CPT has a bunch of ACF select and text fields, as well as a WYSIWYG editor (the old-style TinyMCE editor).

At the beginning of this function, I want it to check to see if the post is dirty - content added or edited in the TinyMCE editor, any of the select or text fields updated - so that I can throw a warning to the user that the post must be published or updated before clicking the button to run my function.

There isn't any code snippits that I can provide in this instance... because I don't know what I'm looking for to see if the post is dirty.

发布评论

评论列表(0)

  1. 暂无评论