Can not edit / delete custom elements
Jakuboslav opened this issue · 2 comments
Hello,
I have an issue, and I can not find solution. I created custom tool, for adding related content. It is simple div, with some data. I didn't use new ContentEdit.Static()
anywhere in this tool.
When I create element via this tool, I can remove it and it works nice. But when I save the page and load it again, Content tools applies on this element static class and it can not be deleted. Simply it behaves as Static.
I recorded sample video of this behavior. So you can see what I am talking about.
Is there any special property I have to attach to this element to make it editable everytime?
Thanks in advance.
You will need to tell CT (or ContentEdit really) how to recognise this element when parsing the page. By default div wont be mapped to any ContentEdit.Element
class and so will be default parsed as a static element.
For example ContentEdit.Text
element is assigned to the following HTML tags:
ContentEdit.TagNames.get().register(
ContentEdit.Text,
'address',
'blockquote',
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'p'
)
Ref: https://github.com/GetmeUK/ContentEdit/blob/master/src/scripts/text.coffee#L532
You'd need to do something similar for your element, however, since you're using a div
I'd recommend using a custom element type name, for example make sure your div is always rendered with the tag data-ce-tag="mycustomelement"
:
<div data-ce-tag="mycustomelement">...</div>
And then register your custom tag with your custom element:
ContentEdit.TagNames.get().register(
MyCustomElement,
'mycustomelement'
)
Thanks, its solved my issue.