backbone-partial-render
This package allows you to render your Backbone Views by updating the
View's DOM rather than completely replacing it every time you
render
. This is similar to how React renders HTML. You can also have
Backbone leave custom rendering that happens outside render
in
place.
Install
npm install backbone-partial-render
on npm
Usage
You have a template that renders Backbone Model data as it updates (with the help of your Backbone View).
Because we're in the real world you also have to update something in
your markup outside the normal render
workflow. Now you start
doubting yourself. "Did I do this right?" "Why doesn't Backbone take
this into consideration?" "Is my whole life a lie?"
Not anymore!
With backbone-partial-render you can keep using render
like normal
and do all the custom UI work you want and never the twain shall
meet.
Your page:
Your JS:
var PartialViewUpdateMixin = ;var $ = ;var Backbone = ;var _ = ; var Book = BackboneModel; var BookView = BackboneView;_; ;
Now you can render all the books you want and look at delectable cheeseburgers at the same time.
Additionally, your form inputs won't be ruined and input focus will be unaffected.
options
renderByPatching
by default passesthis.model.attributes
to the template when rendering. You can override this by passing adata
parameter. For example:renderByPatching({data: this.serialize()})
.
pull requests
You submit em, I'll merge em.
dedication
I dedicate this package to my family, my other family (BuzzFeed), and of course Cthulhu.