bergie/create

How to make a list editable?

BuddhaOhneHals opened this issue · 1 comments

We're currently trying to integrate create.js into one of our projects. With standard paragraphs, it works like a charm.

But at the moment, I try to make a list editable and can't get it running. The user should be able to edit every single list item and add new list items to the list. When saving, the list items should be sent as an array to the backend. Is this possible?

What I have at the moment is following HTML:

<div about="/my/text">
    <h2 property="title">Heading</h2>
    <ul property="items" rel="dcterms:hasPart">
        <li>List item 1</li>
        <li>List item 2</li>
    </ul>
</div>

The user can edit every list item and can add new ones. When saving, the following content will be sent to the backend:

{
    "@subject":"<46>",
    "@type":"<http://www.w3.org/2002/07/owl#Thing>",
    "<http://viejs.org/ns/title>":"Lorem",
    "<http://viejs.org/ns/items>":
        "<li>Lorem ipsum...</li><li>Lorem ipsum...2</li> "
}

Is there a way of editing lists and send correct JSON back to the backend?

Thanks,
Timo

To get the JSON you'd expect, you need to make the list items their own entities in RDFa. Like this:

<div about="foo">
  <h1 property="title">Hello, world</h1>
  <ul rel="items">
     <li about="bar"><span property="content">List item</span></li>
  </ul>
</div>