Ember Views w/ jQuery Plugins and Ember Data


#1

Hello Ember!

I have a calendar jQuery plugin that I’m wrapping in a view:

App.Calendar = Em.View.extend({
    didInsertElement: function(){
        // creation of plugin...
    }
});

This plugin needs an array of the events that I want rendered. The events are being loaded through Ember-Data.

How do I create this array of events?

The only way I’ve been able to solve this is through promises and Ember array functions:

this.get('controller.events').then(function(emEvents){
    var events = [];
    emEvents.map(function(item){
        var event = {
        "title": item.get("name"),
        "startTime": item.get("startTime"),
        "endTime": item.get("endTime")
        };
        events.push(event);
    });
    // create plugin with events array
});

I don’t know if this good Ember design or the way I should be doing it.

Also if I want data binding, how do I create that? (the calendar plugin allows the user to edit the events)