How to exclude elements from cloning in a group?
- This topic has 4 replies, 2 voices, and was last updated 3 years, 6 months ago by
Long Nguyen.
-
AuthorPosts
-
April 18, 2022 at 4:37 AM #35688
Gerard Halligan
ParticipantHi,
Hopefully, someone can help with this.
I have a clone group that I dynamically fill with additional div's and image elements that I don't want to clone as they are cloning with the images already added. I can't add the elements outside of the group, since then the images won't be under the correct cloned group. So, is there any way to mark elements to not clone? Or is there an action/filter that gets called before a cloned group is displayed?
Thanks,
GerApril 18, 2022 at 10:52 PM #35701Long Nguyen
ModeratorHi Gerard,
It's not possible to exclude a subfield from a cloning group. But you can set the subfield to not clone the default value, please refer to this documentation https://docs.metabox.io/extensions/meta-box-group/#clone-default-values
Or find a filter here https://docs.metabox.io/category/filters/
April 19, 2022 at 5:02 AM #35707Gerard Halligan
ParticipantHi Nguyen,
Thanks for help.
What I'm doing is in the clone group, I have a geo lookup that returns the looked up location's google images and displays them. The user can then select an image to save as the main image for that location.
They can add multiple locations and images.The way I insert the images from google is to insert a div and set them image as it's background. I also insert image elements for each of the other images returned from google places for that location. So, since this is all added by js, the default value doesn't have an effect. Each time I click add new clone, the images from the previous clone are duplicated.
I had a look at the filters, but I am unsure which would work in this situation. Do any of these filters get called when a group is cloned?
Thanks,
GerApril 19, 2022 at 7:49 AM #35708Gerard Halligan
ParticipantHi Nguyen,
I was able to work around this. I used the listener I had added for the clone button click event to search for the duplicate div and remove it. I had to add a delay, so the cloned elements get created, so there is a slight flicker of the images before they are removed.
As an added feature for clone groups, could you look into a way to exclude elements with a specific class for example?
Thanks,
GerApril 19, 2022 at 9:19 PM #35717Long Nguyen
ModeratorHi,
I'm going to inform the developer team to consider adding a setting to exclude a subfield from the clone group to the to-do list for the future development of the plugin. Thanks.
-
AuthorPosts
- You must be logged in to reply to this topic.