Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

ampersand-view-jquery-mixin

1.0.0 • Public • Published

ampersand-view-jquery-mixin

A mixin for extending ampersand-view with this.$ and this.$el known from Backbone views. This makes migrating Backbone or HumanJS views to Ampersand a bit easier. Includes a dependency to jQuery 2.

install

npm install ampersand-view-jquery-mixin

usage

This will load jQuery via require()

var View = require('ampersand-view');
var jqueryMixin = require('ampersand-view-jquery-mixin');
 
 
module.exports = View.extend(jqueryMixin, {
    sampleMethod: function () {
        // now we've got jQuery helpers
        this.$( ... );
        this.$el[0];
        // ...
    }
});

usage when jQuery is already available as window.$

This will use an existing window.$ so that not another copy of jQuery is loaded.

var View = require('ampersand-view');
var jqueryMixin = require('ampersand-view-jquery-mixin/no-bundled-jquery');
 
 
module.exports = View.extend(jqueryMixin, {
   // ...
});

license

MIT

install

npm i ampersand-view-jquery-mixin

Downloadsweekly downloads

16

version

1.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability