Giter VIP home page Giter VIP logo

Comments (4)

nathanboktae avatar nathanboktae commented on July 24, 2024

By design. You can't instantiate an abstract class in OOP, right? same thing.

You are overthinking it. Try:

  route('colors', {path: '/colors', routeClass: ColorsIndexRoute}, function () {
    route('colors.new', {path: 'new', routeClass: ColorsCreateRoute});  
  })

btw routeClass is probably a react-cherrytree thing, it's not core to cherrytree. But my solution still applies. We have a navigation bar in a knockout-based application, and it marks it active by looking for the colors named route in any of the routes in router.state.routes.

from cherrytree.

blikblum avatar blikblum commented on July 24, 2024

By design. You can't instantiate an abstract class in OOP, right? same thing.

The abstract route is the only primitive provided by cherrytree to create a index route similar to what ember provides, as pointed in the docs, if there's another way i'll be glad use it

 route('colors', {path: '/colors', routeClass: ColorsIndexRoute}, function () {
    route('colors.new', {path: 'new', routeClass: ColorsCreateRoute});  
  })

It will not work because ColorsCreateRoute will become child of ColorsIndexRoute when its a sibling

The colors route has an outlet element (similar to Ember outlet or VueRouter router-view) where the children is rendered

something like

<div>
<h1>Colors<h1>
  <div class="outlet"></div> //-> here colors.index or colors.new or colors.show are rendered
</div>

Actual code: https://github.com/blikblum/marionette-wires-revisited/blob/master/src/main.js

from cherrytree.

nathanboktae avatar nathanboktae commented on July 24, 2024

OK I see the use case - there is a common shell for each of the children, but you can't route to that shell you need to pick a sibling.

from cherrytree.

KidkArolis avatar KidkArolis commented on July 24, 2024

Sorry I missed the issue when you originally posted!

Hm, interesting problem, I guess a ~dirty workaround is to just do something like router.isActive(route.replace('.index', '').replace('index', 'app')). Which is kind of semantically correct - if you wanted to know if 'books.index' is active, you'd do isActive('books.index'), but you want to know if 'books' is active, so you need to do isActive('books').

I'll look over your PR and the other issue now.

from cherrytree.

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.