Coder Social home page Coder Social logo

Support for LayoutViews about marionette-vdom HOT 9 CLOSED

jklmli avatar jklmli commented on September 24, 2024
Support for LayoutViews

from marionette-vdom.

Comments (9)

themindfuldev avatar themindfuldev commented on September 24, 2024

Hey @jiaweihli - as far as I understand, LayoutView extends from ItemView which is being covered, and it also doesn't do any specific rendering on its own (instead, it manages Regions and put them to render) so initially I thought there was not much else to be done for it. The code is here: https://github.com/marionettejs/backbone.marionette/blob/master/src/layout-view.js

Anyhow, I can't take my analysis for granted so if you see any potential for implementing VDOM please bring it up, and if you feel so, please be more than welcome to join us playing with it as well :)

from marionette-vdom.

jeffijoe avatar jeffijoe commented on September 24, 2024

Support for layout views would ultimately make fine-grained UI updates on a per-attribute basis redundant - change: 'render' all the way. :P

from marionette-vdom.

jklmli avatar jklmli commented on September 24, 2024

As @jeffijoe mentioned, the issue is that sometimes LayoutViews are completely re-rendered - this destroys its child ItemViews.

from marionette-vdom.

themindfuldev avatar themindfuldev commented on September 24, 2024

I see. so yes it would be nice to add LayoutViews specific support that won't destroy its ItemViews.

@jiaweihli I just saw your post on Gitter, is your CompositeView suffering from the same thing?

Two things that I wanted to understand are:
a) Is your LayoutView / CompositeView composed only by VDOM ItemViews?
b) If not, would you please try that and tell me if it would still re-create everything?

from marionette-vdom.

jklmli avatar jklmli commented on September 24, 2024

A:
Sometimes, sometimes not.

B:
Yes, it would still re-create everything, since I'm binding change: 'render' in modelEvents.

I've run into each of these cases:

  • I need to re-render a portion of the view's template (it depends on a model attribute), which forces onRender and re-rendering my children.
  • I want to re-render a specific LayoutView child.
  • I need to re-render a CompositeView child because I need to re-evaluate its attachHtml function.

from marionette-vdom.

themindfuldev avatar themindfuldev commented on September 24, 2024

Gotcha. Thanks! I will have a look this Sunday

from marionette-vdom.

themindfuldev avatar themindfuldev commented on September 24, 2024

I have just released v0.2.1 with Marionette 3 support, which replaces LayoutView and ItemView with just a View. Hence, I'm closing this issue since everything will be covered already by View.

from marionette-vdom.

trystian1 avatar trystian1 commented on September 24, 2024

In our application we support it by creating a layoutView which extends from:

var LayoutView = Marionette.LayoutView;


  return LayoutView.extend({
        setElement: MarionetteVDOM.ItemView.prototype.setElement,
       attachElContent: MarionetteVDOM.ItemView.prototype.attachElContent,
       remove: MarionetteVDOM.ItemView.prototype.remove
  });

To render on model change we simply added:

this.listenTo(this.model, 'change', this.render);

from marionette-vdom.

themindfuldev avatar themindfuldev commented on September 24, 2024

Cool. Thanks @trystian1 - your solution would be the case for Marionette 2.

from marionette-vdom.

Related Issues (8)

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.