Sha256: a148792117cb442f14448a5aff7577ad55a0b5986a0295e357bf25b061abbe22

Contents?: true

Size: 1.02 KB

Versions: 5

Compression:

Stored size: 1.02 KB

Contents

HAL.Views.Resource = Backbone.View.extend({
  initialize: function(opts) {
    var self = this;

    this.vent = opts.vent;

    this.vent.bind('response', function(e) {
      self.render(new HAL.Models.Resource(e.resource));
    });

    this.vent.bind('fail-response', function(e) {
      self.vent.trigger('response', { resource: null, jqxhr: e.jqxhr });
    });
  },

  className: 'resource',

  render: function(resource) {
    var linksView = new HAL.Views.Links({ vent: this.vent }),
        propertiesView = new HAL.Views.Properties({ vent: this.vent }),
        embeddedResourcesView

    linksView.render(resource.links);
    propertiesView.render(resource.toJSON());

    this.$el.empty();
    this.$el.append(linksView.el);
    this.$el.append(propertiesView.el);

    if (resource.embeddedResources) {
      embeddedResourcesView = new HAL.Views.EmbeddedResources({ vent: this.vent });
      embeddedResourcesView.render(resource.embeddedResources);
      this.$el.append(embeddedResourcesView.el);
    }

    return this;
  }
});

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pact_broker-1.3.2.rc1 vendor/hal-browser/js/hal/views/resource.js
pact_broker-1.3.1 vendor/hal-browser/js/hal/views/resource.js
pact_broker-1.3.0 vendor/hal-browser/js/hal/views/resource.js
pact_broker-1.2.0 vendor/hal-browser/js/hal/views/resource.js
pact_broker-1.1.0 vendor/hal-browser/js/hal/views/resource.js