Collections in Create.js

39 Views Asked by At

According to Create.js' integration guide, it should be possible to create editable collections of blocks.

Relationships between entities allow you to communicate structured content to Create.js, which will turn them into Backbone collections. For example, to annotate a list of blog posts:

<div about="http://example.net/blog/" rel="dcTerms:hasPart">
  <div about="http://example.net/my-post">...</div>
  <div about="http://example.net/second-post">...</div>
</div>

This dcTerms:hasPart doesn't seem to be present explicitly in Create.js; it's probably from a vocabulary. How can one show to Create.js that this content is a collection and make it show the "Add" button? In my case, I simply have sections which contain <h2>, <h3> and <article>s.

EDIT: Using rel="hasPart" in my <section>, the button appears. Problem is Create always uses the first element as a template. In this case, it uses my <h2> as template, which is not what I intended. So my question now would be how to trigger the "add" event in my section?

1

There are 1 best solutions below

0
ecc On BEST ANSWER

Hackish solution:

Using javascript, I created a new section or article in the DOM, then restarted Create calling $('body').midgardCreate({...}) again. Create will now recognize the new block. When I edit some fields in the block, the "Save" button is enabled and I can submit the new block.