GithubHelp home page GithubHelp logo

Comments (3)

mxriverlynn avatar mxriverlynn commented on May 3, 2024

So, having sat on this all day and thinking about it in the back of my head, I'm slowly coming to the conclusion that what I have is good enough. The amount of code that it would take to move this to the next step of having it be a self-contained hierarchy that knows how to handle the top level item whether or not a model exists, is going to push me in to diminishing returns and probably not be worth the headache that it would cause in terms of maintenance.

from backbone.marionette.

bennage avatar bennage commented on May 3, 2024

I've looked over your sample, I don't have a better suggestion (though I am still a little backbone baby).

I had a similar problem though in a non-backbone context recently. My solution was to examine the top-level item and "normalize" it to fit the pattern that the children were expected to follow. Perhaps that's what you were trying to do here (and I'm just missing it):

initialize: function(){
    if (this.model){
      this.collection = this.model.nodes;
    }
}

Though I would have expected something more like:

initialize: function() {
    var items = this.model;
    if(_.isArray(item)) {
        this.model = { nodes: items };
    }
}

Again, I'm pretty ignorant of backbone still. I suspect it's a bad idea to clobber the model like that.
I say to move ahead with it until it hurts, and if it starts to hurt then look for a better solution.

from backbone.marionette.

mxriverlynn avatar mxriverlynn commented on May 3, 2024

moving forward with the structure as-is

from backbone.marionette.

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.