Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ampersand-view

Package Overview
Dependencies
Maintainers
3
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ampersand-view - npm Package Compare versions

Comparing version 6.0.9 to 6.0.10

2

package.json
{
"name": "ampersand-view",
"description": "A smart base view for Backbone apps, to make it easy to bind collections and properties to the DOM.",
"version": "6.0.9",
"version": "6.0.10",
"author": "Henrik Joreteg <henrik@andyet.net>",

@@ -6,0 +6,0 @@ "browser": "./ampersand-view.js",

@@ -101,3 +101,3 @@ # ampersand-view

The events hash allows you to specify declarative callbacks for DOM events within the view. This is much clearer and less complex than calling `$('selector').on('click', ...)` or `el.addEventListener('click', ...)` everywhere.
The events hash allows you to specify declarative callbacks for DOM events within the view. This is much clearer and less complex than calling `el.addEventListener('click', ...)` everywhere.

@@ -270,3 +270,3 @@ * Events are written in the format `{"event selector": "callback"}`.

* `collection` {Backbone Collection} The instantiated collection we wish to render.
* `itemViewClass` {View Constructor} The view constructor that will be instantiated for each model in the collection. This view will be instantiated with a reference to the model and collection and the item view's `render` method will be called with an object containing a reference to the containerElement as follows: `.render({containerEl: << element >>})`.
* `ItemView` {View Constructor | Function} The view constructor that will be instantiated for each model in the collection or a function that will return an instance of a given constructor. `options` object is passed as a first argument to a function, which can be used to access `options.model` and determine which view should be instantiated. This view will be used with a reference to the model and collection and the item view's `render` method will be called with an object containing a reference to the containerElement as follows: `.render({containerEl: << element >>})`.
* `containerEl` {Element} The element that should hold the collection of views.

@@ -287,4 +287,5 @@ * `viewOptions` {Object} [optional] Additional options

```javascript
// some view for individual items in the collection
// some views for individual items in the collection
var ItemView = AmpersandView.extend({ ... });
var AlternativeItemView = AmpersandView.extend({ ... });

@@ -311,6 +312,22 @@ // the main view

// }
this.renderCollection(this.collection, ItemView, this.$('.itemContainer')[0], opts);
this.renderCollection(this.collection, ItemView, this.el.querySelector('.itemContainer'), opts);
return this;
}
})
});
// alternative main view
var AlternativeMainView = AmpersandView.extend({
template: '<section class="sidebar"><ul class="itemContainer"></ul></section>',
render: function (opts) {
this.renderWithTemplate(this);
this.renderCollection(this.collection, function (options) {
if (options.model.isAlternative) {
return new AlternativeMainView(options);
}
return new MainView(options);
}, this.el.querySelector('.itemContainer'), opts);
return this;
}
});
```

@@ -430,3 +447,3 @@

* viewInstance {Object} Any object with a `.remove()`, `.render()` and an `.el` property that is the DOM element for that view. Typically this is just an instantiated view.
* containerEl {Element | String | jQueryElement} This can either be an actual DOM element or a CSS selector string such as `.container`. If a string is passed human view runs `this.$("YOUR STRING")` to try to grab the element that should contain the sub view.
* containerEl {Element | String} This can either be an actual DOM element or a CSS selector string such as `.container`. If a string is passed human view runs `this.get('YOUR STRING')` to try to grab the element that should contain the sub view.

@@ -433,0 +450,0 @@ This method is just sugar for the common use case of instantiating a view and putting in an element within the parent.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc