Create.js 中的集合
Collections in Create.js
根据 Create.js' integration guide,应该可以创建可编辑的块集合。
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>
这个 dcTerms:hasPart
似乎没有明确出现在 Create.js 中;这可能来自词汇表。如何向 Create.js 显示此内容是一个集合并使其显示 "Add" 按钮?就我而言,我只有包含 <h2>
、<h3>
和 <article>
的部分。
编辑:在我的 <section>
中使用 rel="hasPart"
,按钮出现。问题是 Create 总是使用第一个元素作为模板。在这种情况下,它使用我的 <h2>
作为模板,这不是我想要的。所以我现在的问题是如何在我的部分触发 "add" 事件?
骇人听闻的解决方案:
使用 javascript,我在 DOM 中创建了一个新的部分或文章,然后再次调用 $('body').midgardCreate({...})
重新启动创建。 Create 现在将识别新块。当我编辑块中的某些字段时,启用了 "Save" 按钮,我可以提交新块。
根据 Create.js' integration guide,应该可以创建可编辑的块集合。
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>
这个 dcTerms:hasPart
似乎没有明确出现在 Create.js 中;这可能来自词汇表。如何向 Create.js 显示此内容是一个集合并使其显示 "Add" 按钮?就我而言,我只有包含 <h2>
、<h3>
和 <article>
的部分。
编辑:在我的 <section>
中使用 rel="hasPart"
,按钮出现。问题是 Create 总是使用第一个元素作为模板。在这种情况下,它使用我的 <h2>
作为模板,这不是我想要的。所以我现在的问题是如何在我的部分触发 "add" 事件?
骇人听闻的解决方案:
使用 javascript,我在 DOM 中创建了一个新的部分或文章,然后再次调用 $('body').midgardCreate({...})
重新启动创建。 Create 现在将识别新块。当我编辑块中的某些字段时,启用了 "Save" 按钮,我可以提交新块。