
Security News
rv Is a New Rust-Powered Ruby Version Manager Inspired by Python's uv
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
backbone_views
Advanced tools
Provides some basic views to help you get started using Backbone
All examples below are written in coffeescript. (That's what this library is written in.)
Provides an easy interface to mixins. All class based views in this package will use this as their base class.
bv = require("backbone_views")
class MyView extends bv.views.MixinView
mixins: [bv.mixins.SelectorMixin]
A mixin is just a class. The prototype will be mixed in the current class.
If a mixin
method is provided by the mixin, the it will be called during
the view's initialize
method.
This view also provides basic rendering. It will call the template property of the view if it exists.
The views below are just simple implementations that use the mixins listed at the bottom of the doc. For complicated stuff, you probably should write your own.
Uses the ListMixin
below and a DetailView
to provide a functioning list.
This view only requires that you give it a collection and it will make
an auto managed list.
A simple view that uses the FormMixin
to create and add a model to a
collection. You must provide a collection for this view to work.
Uses the DetailMixin
below
A simple view that updates a model using the FormMixin
A simple view that provides a confirm form before destroying a model
Gives function to render a nunjucks form.
bv = require("backbone_views")
class MyView extends bv.views.MixinView
mixins: [bv.mixins.NunjucksMixin]
template: require("my_view.html")
You can provide a getContext
function to extend the context
Selects elements after rendering
bv = require("backbone_views")
class MyView extends bv.views.MixinView
ui:
input: ".form input#foo"
# here is how you can use it, it will be jQueryied
myFunc: () -> alert @ui.input.val()
Provides a renderForm
method to render a form from the npm forms package.
(Dang, that sentence is not formed well :D )
bv = require "backbone_views"
forms = require "forms"
class MyView extends bv.views.MixinView
mixins: [bv.mixins.FormMixin]
form: forms.create(
name: form.fields.string(required: true)
)
A form mixin that provides a bootstrapping form render function bootstrapField
for those who use bootstrap3
When this mixin is provided a collection it will register listeners to auto populate the collection in the view.
If a listSelector
isn't provided or selects nothing,
it will assume the list should be populated on the view's el
.
If an emptySelector
is provided, it will hide/show the selector's results
whenever the list is empty/exists
bv = require("backbone_views")
Backbone = require("backbone")
class MyView extends bv.views.MixinView
mixins: [bv.mixins.ListMixin]
listSelector: ".list"
emptySelector: ".empty"
collection: new Backbone.Collection([{foo: "boo"}])
template: '...'
This provides an easy way to bind properties to a view.
Set the property name and a selector on the bindings
property and then
this model and the dom will be kept in sync
By default it will autobind unbound attrs to "data-{{ name }}", but you
can set the autoBind
property to change it to something else or turn
off this feature.
You can further customize what bound elements will do by setting the "data-{{ name }}" value:
by default it will replace the contents of the element
bv = require("backbone_views")
Backbone = require("backbone")
class MyView extends bv.views.MixinView
mixins: [bv.mixins.DetailView]
bindings:
fruit: "div .apple"
template: '...'
FAQs
A collection of views similar to django views
The npm package backbone_views receives a total of 2 weekly downloads. As such, backbone_views popularity was classified as not popular.
We found that backbone_views demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.