0

Using Ember and Handlebars I'm trying to display an ordered list of notes with nested sublists of notes (using jquery nestedSortable, and rails gem awesome_nested_set). I have my notes in the correct order, and each note has a parent_id in the database and in Ember Data.

Basically, the handlebars template should loop through each note, and then loop through each sub-note within that note.

To do this correctly I have a feeling I need a nested 'children' array, but I'm not fully certain whether that's true, or the best way to do that. Computed properties? Handlebars Helpers? Any advice would be awesome.

Updates

I received a tip that I'll try and work with:

App.Note = DS.Model.extend({
    (…)
  notes: DS.hasMany(‘notes’)
});

Then in the template, for each node, just render its (children) “notes” :

{{#each}}
    {{#each note in notes}}
        (…)
    {{/each}}
{{/each}}

Saving on every drag and drop is another part to this puzzle, but one step at a time...

4

0 回答 0