Jump To …

EntityView.js

src/view/

lobal VIE:false Backbone:false _:false

if (!VIE.prototype.view) {
    VIE.prototype.view = {};
}

VIE.prototype.view.Entity = Backbone.View.extend({
    initialize: function(options) {
        this.service = options.service ? options.service : 'rdfa';
        this.vie = options.vie;

Ensure view gets updated when properties of the Entity change.

        _.bindAll(this, 'render', 'renderAbout');
        this.model.on('change', this.render);
        this.model.on('change:@subject', this.renderAbout);
    },

Rendering a view means writing the properties of the Entity back to the element containing our RDFa annotations.

    render: function() {
        this.vie.save({
                element: this.el,
                entity: this.model
            }).
            to(this.service).
            execute();
        return this;
    },

    renderAbout: function () {
        this.vie.service(this.service).setElementSubject(this.model.getSubjectUri(), this.el);
    }
});

generated Wed Dec 05 2012 19:56:05 GMT+0100 (CET)
VIE