Code Monkey home page Code Monkey logo

Comments (7)

thomasdavis avatar thomasdavis commented on June 26, 2024

Thanks Thomas, you are exactly right. I am working on the View Manager write now that controls the life cycle of views and stops zombie views, will be pushing in the next few hours. Thanks again!

from backboneboilerplate.

thomasdao avatar thomasdao commented on June 26, 2024

Hi,

I think it would be a nice improvement when we return 'this' on the render method.

ChildPage = Backbone.View.extend {
render: function() {
// do something
return this;
}
}

Sometime, from master page we want to append a child page, we could do:
childPage = new ChildPage()
$(element).append(childPage.render().el)

from backboneboilerplate.

engram-design avatar engram-design commented on June 26, 2024

I've also had issues with the current View Manager, which, while great, doesn't clean up properly. I came across this after loading views where events defined in (events.js) were being triggered multiple times. To work around this, I'm using undelegateEvents() on the previous view before creating a new one.

I'm aware that the VM isn't fully implemented yet, but any plans on setting this up?

from backboneboilerplate.

thomasdavis avatar thomasdavis commented on June 26, 2024

on second thought undelegateEvents is probably the only default cleanup a view manager should do and also calling clean() if it has been defined. What do you think?

from backboneboilerplate.

engram-design avatar engram-design commented on June 26, 2024

I'm certainly no expert, but that's just what I'm doing! Sounds good :)

Also, on the subject of VM - is it supposed to re-use already created views when called again? As currently, it doesn't seem to, and just creates a new view when create is called. In fact, views[name] is never defined.

Thanks for your quick response by the way!

from backboneboilerplate.

thomasdavis avatar thomasdavis commented on June 26, 2024

So in the view manager the views should always be created fresh, if you want to maintain a view you can do so using your applications logic.

Some goals I had for the view manager were

  • clean up !important
  • managing children / nested views
  • a basic signalling of view creation to the app
  • eventually more advanced event delegation e.g. the ability to make all event listeners on a view dormant etc
  • handle dynamic reusable views such as table rows

For now I've changed the unbind() to undelegateEvents().

from backboneboilerplate.

engram-design avatar engram-design commented on June 26, 2024

Ok, that clears that up - sounds good. Thanks mate!

from backboneboilerplate.

Related Issues (20)

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.