Ways to display or conceal dual views within a single Marionette js region

In my LayoutView, I have set up two regions: the filter region and the main region (Content Region). The main region displays a view based on the selection made in the filter region.

Currently, I have a view for the main region called Current Year view. However, I need guidance on creating a view for a different Wireframe that is attached to this question panel.

// Application Bootstrap
var App = new Marionette.Application();

// Add a region
App.addRegions({
  main: "#app"
});

/*DATA*/
var data = {
  "accounts": [{
    "accountNumber": "AllAccounts",
    "assets": [{
        "assetName": "ASSET 1",
        "isin": "GB0008533564",
        "grossProfit": [{
          "assetCost": "500",
          "units": "10",
          "netGainLoss": "20"
        }]
      },
      {
        "assetName": "ASSET 2",
        "isin": "GB0008533565",
        "grossProfit": [{
          "assetCost": "500",
          "units": "10",
          "netGainLoss": "20"
        }]
      },
      {
        "assetName": "ASSET 3",
        "isin": "GB0008533566",
        "grossProfit": [{
          "assetCost": "500",
          "units": "10",
          "netGainLoss": "20"
        }]
      }
    ]
  }]
};

// Rest of the code remains same

...

.container {
  padding-top: 10px;
}
<div class="container">
  <div class="row">
    <div class="col-md-12">
      <div id="app"></div>
    </div>
  </div>
</div>

<!--TEMPLATES -->
<script id="layout-view-template" type="text/handlebars-template">
  <!-- Layout View Template HTML Code Here -->
</script>

<script id="filter-view-template" type="text/handlebars-template">
  <!-- Filter View Template HTML Code Here -->
</script>

<script id="report-view-template" type="text/handlebars-template">
  <!-- Report View Template HTML Code Here -->
</script>

<script id="report-row-template" type="text/handlebars-template">
  <!-- Report Row Template HTML Code Here -->
</script>

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" />
<!-- Include necessary CDN scripts here -->

Please use the provided data below to display the Past 2 Years view, where only slight changes are made in the grossProfit array objects.


var data = {
  "accounts": [{
    "accountNumber": "AllAccounts",
    "assets": [{
        "assetName": "ASSET 1",
        "isin": "GB0008533564",
        "grossProfit": [{
            "assetCost": "500",
            "units": "10",
            "netGainLoss": "20"
          },
          {
            "assetCost": "500",
            "units": "10",
            "netGainLoss": "20"
          }

        ]
      },
      {
        "assetName": "ASSET 2",
        "isin": "GB0008533565",
        "grossProfit": [{
            "assetCost": "500",
            "units": "10",
            "netGainLoss": "20"
          },
          {
            "assetCost": "500",
            "units": "10",
            "netGainLoss": "20"
          }

        ]
      },
      {
        "assetName": "ASSET 3",
        "isin": "GB0008533566",
        "grossProfit": [{
            "assetCost": "500",
            "units": "10",
            "netGainLoss": "20"
          },
          {
            "assetCost": "1000",
            "units": "10",
            "netGainLoss": "20"
          }

        ]
      }
    ]
  }]
};

Answer №1

When dealing with showing different composite views within the main region, there are a few cases to consider:

Case 1: If you need to display completely different composite views in the main region, create a separate layout called 'ResultLayout' to be rendered in the Main Region. Initialize both composite views in ResultLayout and switch between them based on filter changes.

In the scenario of dynamic data:

Case 2: Again, if you have to show different composite views in the main region, utilize 'ResultLayout'. Initially, display the default filter selected and corresponding view within ResultLayout. Upon filter change, trigger an event from FilterView listened to in ResultLayout to fetch the collection according to the filters and render the appropriate composite view.

The hierarchy for this case is LayoutView -> Filter Region and Main Region -> ResultLayout -> CompositeView1 or CompositeView2.

Case 3: To keep the composite view the same, simply update the collection and render the view accordingly.

I trust this explanation is helpful!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Learn how to increase a value with each dynamically clicked button in JavaScript

Whenever I try to increment the value by clicking the like button, it seems to be increasing but not in sync with the actual button count. How can I fix this issue? index.html <div class="row"> <div class="col-md-4"> ...

The context of the Nuxt.js3 plugin loses its definition

Currently, I am working on a project that involves Nuxt.js3 and supabase integration. In my plugins/supabase.server.js file (I am still unsure whether using server or client is the best approach), I want to call "supabase = createClient(~~)" from index.vu ...

In what way can I decipher a section of the URL query string within my AngularJS application?

Here is a snippet of code that I am working with: var search = $location.search(); if (angular.isDefined(search.load) && search.load != null) { if (search.load = "confirmEmail") authService.confirmEmailUserId = search.userI ...

Leveraging functionality from an imported module - NestJS

Currently, I am utilizing a service from a services module within the main scaffolded app controller in NestJS. Although it is functioning as expected - with helloWorldsService.message displaying the appropriate greeting in the @Get method - I can't ...

Is the branch of ExtJS 4.1 TreeStore lazy loading extending?

I am working on implementing lazy loading of tree branches in an MVC application using extjs4.1. The branches are located on different URLs and I have faced several challenges along the way. Unfortunately, at this point, the branching functionality is not ...

Implementation of multiple angular guards causing a crash on the page

I have been attempting to implement separate guards for distinct pages. Essentially, I am checking a boolean parameter to determine if a user is logged in or not. Below are the two guard.ts codes that I am using: export class IsAuthenticatedGuard implemen ...

Delete all HTML functionalities

Is there a way to strip HTML functions when using a text area so that the content shows as plain text in a new post (div)? For example, if I type "Hello", I want it to appear as "< b > Hello < b / >", showing the whole code. Here is the code snippe ...

Unable to modify the selector to "Remove preview files" on click in PHP and JavaScript

During the process of uploading multiple files (using <input type="file" multiple/>) with preview image file and successfully removing the image preview and file data, I encountered a problem. The issue arises when attempting to change the selector ...

Preventing Click Events from Firing During Drag in JavaScript

I have implemented a code for dragging containers left or right, which is functioning properly. Users can also click on the "thumb". However, I am facing an issue where a click event occurs even after dragging. I want to ensure that only either drag or cli ...

Harnessing the power of lazysizes with WebP

I've been working on optimizing our site through the Google Lighthouse audit, and it's clear that images are a major focus. Right now, my main goal is to address the issue of 'Deter offscreen images' highlighted in the audit. To tackle ...

Efficient Local Database with Javascript

When storing a substantial amount of data, such as a big hashmap in JavaScript, what would be the optimal format for quick retrieval while also supporting Unicode? Would XML or JSON be better suited for this purpose? ...

Utilize AngularJs and JavaScript to upload information to a JSON file

Exploring the realm of Angular JS, I am on a quest to create a CRUD form using AngularJs and Json with pure javascript without involving any other server side language. The script seems to be functioning well but is facing an obstacle when it comes to writ ...

Is there a way to make the submit button navigate to the next tab, updating both the URL and the tab's content as well?

I am encountering an issue with my tabs for Step1 and Step2. After pressing the submit button in Step1, the URL updates but the component remains on tab1. How can I resolve this so that the user is directed to the Step2 tab once they click the submit butto ...

Animating a Canvas to Follow Mouse Coordinates

I am looking for a way to animate a circle moving towards specific coordinates, similar to the game . I have attempted using the jquery animate() function, but it is too slow due to the constant updating of the target coordinates. Is there a faster metho ...

Change a camelCase string to ALL_CAPS while adding underscores in JavaScript

Currently, I'm dealing with a situation where I have a list of variables stored in a file that I need to convert into all capital letters and separate them with underscores using JavaScript. The variable pattern looks something like this: AwsKey Aw ...

Serve static files using ExpressJS when a post request is made

My Express server is set up to serve static files for my website and it's working fine: var express = require('express'); var app = express(); var path = require('path'); var p = path.join(__dirname, '../web/public'); app ...

Is there a way to locate all items that satisfy a specific criterion within JSON Data?

Utilizing data from an API-Call, I have established a many-to-many relationship - illustrated with the examples of people and movies. Multiple individuals can watch one movie, and one person can view several movies. In the Angular Frontend, when a person ...

Trouble keeping HTML/Javascript/CSS Collapsible Menu closed after refreshing the page

My issue is that the collapsible menu I have created does not remain closed when the page is refreshed. Upon reloading the page, the collapsible menu is always fully expanded, even if it was collapsed before the refresh. This creates a problem as there is ...

Is there a way to keep a div element anchored at the top of the page until I reach the bottom and then have it stick to the bottom as I continue

I have a question that I hope is clear enough! On my webpage, there is a div at the top that I want to move to the bottom when I scroll and reach the end of the page. Hopefully, you understand what I'm trying to achieve! If anyone has any ideas, I&ap ...

Explaining the process of defining `this.props` and storing data in the global Redux state

I am currently diving into the world of react and Redux and I'm using a react project on GitHub called overcode/rovercode-ui as a learning tool for understanding react and Redux. As I explore this project, I have come across some intriguing questions. ...