Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added method for removing a content hook #69

Closed
wants to merge 1 commit into from
Closed

Added method for removing a content hook #69

wants to merge 1 commit into from

Conversation

funkjedi
Copy link
Contributor

@funkjedi funkjedi commented Mar 5, 2015

Adding method that will remove a content hook and restore the field back to its initial state.

// Remove content hooks from ACF Repeater and Flexible Fields clones
jQuery('.acf-clone .wp-editor-area.qtranxs-translatable').each(function() {
    qTranslateConfig.qtx.removeContentHook(this);
});

@johnclause
Copy link
Member

Hi Tim, what is the status on this? Do you still need this? Why would you need to remove a hook, if we can not to add it to begin with?

@funkjedi
Copy link
Contributor Author

There are two specific use cases both relating to adding and removing custom fields on the fly.

1) ACF keeps a set of dummy fields which are cloned in JS when a user adds a new row of repeatable fields. The problem is that when on post.php or post-new.php all textareas with the .wp-editor-area class automatically have content hooks added to them. This means the hidden dummy fields now have content hooks. When these fields are cloned to make the new set of fields it copies the modifications made by the content hooks. Which prevents us from adding content hooks to the new fields.

2) If the user removes a set of repeatable fields the content hooks need to be removed. Otherwise when the form is submitted the mlContentField fields will still contain the deleted fields. Resulting in the data not actually being deleted.

@johnclause
Copy link
Member

I pushed this to the latest master on github. Is there anything else needed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants