Code Monkey home page Code Monkey logo

Comments (9)

mulderp avatar mulderp commented on June 6, 2024

The situation is also here: https://github.com/pipefishbook/ch_5/tree/zombie_bug/sortui

from backbone.xview.

powmedia avatar powmedia commented on June 6, 2024

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.

mulderp avatar mulderp commented on June 6, 2024

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.

mulderp avatar mulderp commented on June 6, 2024

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.

powmedia avatar powmedia commented on June 6, 2024

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.

mulderp avatar mulderp commented on June 6, 2024

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.

mulderp avatar mulderp commented on June 6, 2024

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.

mulderp avatar mulderp commented on June 6, 2024

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.

mulderp avatar mulderp commented on June 6, 2024

The working example is at: http://pipefishbook.com/ch_5/sortui/#

from backbone.xview.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.