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
herrvigg opened this issue Jun 21, 2018 · 3 comments
Closed

Added method for removing a content hook #69

herrvigg opened this issue Jun 21, 2018 · 3 comments
Labels
legacy PR Legacy PR imported from original repo

Comments

@herrvigg
Copy link
Collaborator

Issue by funkjedi
Thursday Mar 05, 2015 at 18:21 GMT
Originally opened as qTranslate-Team/qtranslate-x#69


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);
});

funkjedi included the following code: https://github.com/qTranslate-Team/qtranslate-x/pull/69/commits

@herrvigg herrvigg added the legacy issue Legacy issue imported from original repo label Jun 21, 2018
@herrvigg
Copy link
Collaborator Author

Comment by johnclause
Tuesday Mar 10, 2015 at 05:44 GMT


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?

@herrvigg
Copy link
Collaborator Author

Comment by funkjedi
Tuesday Mar 10, 2015 at 06:04 GMT


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.

@herrvigg
Copy link
Collaborator Author

Comment by johnclause
Tuesday Mar 10, 2015 at 06:19 GMT


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

@herrvigg herrvigg added legacy PR Legacy PR imported from original repo and removed legacy issue Legacy issue imported from original repo labels Jun 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
legacy PR Legacy PR imported from original repo
Projects
None yet
Development

No branches or pull requests

1 participant