Comments (9)
The situation is also here: https://github.com/pipefishbook/ch_5/tree/zombie_bug/sortui
from backbone.xview.
One thing I noticed, is you need to pass the view el
to jQuery:
Backbone.$('#controls').html((new Controls({
collection: options.router.movies
})).render().el);
from backbone.xview.
Thanks, I tried that too, but maybe it is a good start for debugging. Let's first set:
var controls = new Controls({ collection: options.router.movies });
debugger
Backbone.$('#controls').html(controls.render().el);
When I check controls, I get:
> controls.render().el
<p>Sort:</p>
> controls.template()
"<p>Sort:</p> <button id="by_title">By Title</button> <button id="by_rating">By Rating</button> <button id="by_showtime">By Showtime</button>
from backbone.xview.
When I leave unwrap
out, I get:
> controls.render().el
<p>Sort:</p>
<button id="by_title">By Title</button>
...
But since the element is re-rendered, I get a zombie view later.
from backbone.xview.
I'm not sure what you mean however when using unwrap
the template must have a root element (e.g. wrap the p
and button
in a div
)
from backbone.xview.
Hmm.. ok, I can make my controls div work by using the idea from unwrap directly:
var controls = new Controls({ collection: options.router.movies });
controls.setElement(Backbone.$('#controls'));
Probably there is a nicer way with the addView
approach, but it'll do for now.
Thanks for the feedback!
from backbone.xview.
Ah, this looks already close to what I was looking for:
onRender: function() {
this.controls.setElement($('#controls'));
},
initialize: function(options) {
this.addView('#overview', new MoviesList({
collection: options.router.movies,
router: options.router
}));
this.controls = new Controls({ collection: options.router.movies });
}
from backbone.xview.
What do you think? It is a bit the idea of addView
or? The only difference is that the view is not dynamically added right now, which is fine when it is included in parent template.
from backbone.xview.
The working example is at: http://pipefishbook.com/ch_5/sortui/#
from backbone.xview.
Related Issues (4)
- Add CollectionView
- Template engines HOT 2
- View not cleaned up HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from backbone.xview.