MarionetteJS - Multiple nested side by side views - marionette

I am looking at the example here http://davidsulc.github.io/backbone.marionette-nested-views/ it shows how you can create a list a superheroes and for each hero have an inner list of villains.
How would one extend this to not only list villains for each hero, but also their top three favorite colors? for example.
So I could have something like
Batman
-----------------------------------
Bane | Black
Ra's Al Ghul | Blue
The Joker | Orange
The Riddler |
===================================
Spiderman
-----------------------------------
Green Goblin | Red
Venom | Green
| Violet
===================================
Wonder Woman
-----------------------------------
Ares | Silver
Doctor Psycho | Purple
Silver Swan | White
===================================
In the composite view it is as if I need two sets of itemviews and itemcomtainers, something like
HeroView = Backbone.Marionette.CompositeView.extend({
template: "#accordion-group-template",
className: "accordion-group",
itemView: VillainView,
itemViewContainer: "#villainUL",
itemView2: FavoriteColorView,
itemViewContainer2: "#colorUL",
...
But of course such a thing doesn't exist.
Edit: this http://jsfiddle.net/derickbailey/AdWjU/ will probably serve as a solution, but I will have to wait until the morning to adapt it.

First of all, hopefully you're aware of the blog post I wrote to go with the code: http://davidsulc.com/blog/2013/02/03/tutorial-nested-views-using-backbone-marionettes-compositeview/
Bad news: I think you'll actually need more work to achieve what you want...
The jsFiddle you linked (http://jsfiddle.net/derickbailey/AdWjU/) displays a list of element that are sub-elements. What you want to do is display two separate lists!
Here's what I'd try: you need to replace the VillainView (which is an ItemView) with a layout which we'll call HeroInfo, in this layout you need to declare 2 regions (one for the villain list, the other for the colors). This new layout also won't be rendered within a ul so you can remove the itemViewContainer from the view definition and the template.
Note you might not be able to specify the layout regions as an object (you can't use ids in the template since they'll be repeated, and you might not yet have access to this.$el). If that's the case, you need to initialize them with something like this:
initialize: function(){
// assuming you have an element with class "js-villain-region" in your layout template
this.addRegion("villainRegion", this.$el.find(".js-villain-region").first());
}
Next, you need to define a VillainView and a ColorView (both are collection views) to be displayed in the layout's regions on the "show" event (see example code using a layout here: https://github.com/davidsulc/marionette-gentle-introduction/blob/master/assets/js/apps/contacts/list/list_controller.js#L43
I hope this helps to set you on the right path!
Also, as a side note: this seems to be more challenging than it looks at first glance. If you're doing this as a learning experience, don't get discouraged: you're attempting a challenging, complex view implementation, which will be tricky when first getting into Marionette.

Related

How to use the search bar to filter my leaflet markers

I've made a custom view in Odoo to place partners (from res_partner) on a map (via Leaflet). On this map, it place markers with a pop up that show infos related to the partner. (like this picture)
That good, but I want that when I use the search bar, it filter the markers, to only show those that are relevant.
I'm new to Odoo (so I might ask a stupid question), and we have to use Odoo 9 at work actualy (so we can't use something else).
Ok, I've found out. I just had to use the do_search method, and pass the domain attribute in my query().filter() (like this: query().filter(domain))

What is the best way of creating nested grids with different layouts in Susy 2?

I've got a site layout which is as follows, if you can imagine the structure!
header
branding | search
navigation
home | about | blog | news | contact
main
news
promotion 1 | promotion 2 | promotion 3
more content | more content
side bar first
sidebar second
footer
privacy policy | etc
The widths of these different sections above are all different - some have more gutting/padding than other.
I'm trying to figure out how in Susy 2 the best way of managing different layout contexts and am trying to figure it out in the documentation but with no proper examples, am struggling a little bit. I've tried using, for example, #include layout under the main section but that fails to do what I'm trying to do so I'm guessing I'm not quite understanding the fundamental concepts of Susy 2.
Any help/advice would be appreciated!
Thank you
Just to clarify, I'm not asking for the code for my site structure to be offered, I'm asking for the functions in the Susy 2 library to be clarified a little as there are no examples of the functions in use and how they should be used is not that apparent.
You probably want to use the with-layout mixin, which changes grid settings for a block of nested code:
nav {
#include with-layout($nav-settings) {
// nav layout code, uses nested settings.
}
}
main {
// main layout code, uses global settings.
}

Simile Timeline change order of lines

How do I change the vertical order of event lines in Simile Timeline? Where in the code does it decide what order to put them in?
I have tried looking into this also. I am convinced it is random order.
This not the answer you wanted but try using this timeline
http://almende.github.io/chap-links-library/timeline.html
It is quite flexible, you can choose your create your own layout and use your own CSS/HTML in each individual event.
Edit: Found a attribute that you could use to change the order
trackNum - used to override the automatic layout of events on the
Timeline.
check this wiki for more info: http://simile-widgets.org/wiki/Timeline_EventSources
under "Event Attributes for Developers"

Pinpointing the difference and changes made between two pages in magento 1.6.2

I have two pages that should be using the exact same template and layout.
The correct item layout can be seen below.
http://dokha.co/index.php/medwakh/custom-medwakh-from-white-horse-studios-13.html
The incorrect item layout is below.
http://dokha.co/index.php/shisha-tobacco/al-fakher-shisha-tobacco-1.html
As you can see in the first image the layout of the item is compact. In the second link it is all drawn out.
I am curious to know if you can tell me how to make the second one like the first one, The compact style. I am not sure what modifications could have been made in magento to cause the layout to only show up that way for specific items, as only the items in the category on link 1 behave that way, I would like to know how to make them all behave this way.
Ok, first thing: the layouts are slightly different because in the first example, you have simple product and in the second example you have a configurable product.
So, view.phtml is including different templates in each.
Regardless though, the actually culprit of the expanded space you are seeing in the second example is being caused by a clearing div. Simply remove it.
The div you are looking for is this:
<div class="clearer"></div>
and you will find it in app/design/frontend/your_package/your_theme/template/catalog/product/view.phtml

Zend framework Nesting controllers

Zend framework Nesting controllers
I was wonder if it is possible to have nested controllers.
I have an application that has a page with left bar and right bar.
| --TAB----TAB----TAB--
MyGroups |
|
So I want to have one controller to be as a wrapper for entire page
then have myGroups controller for left bar, and for right side, there are many tabs that would show based on some selections.
So I want to have one controller for each tab.
This is a very big application and each of those tabs do lots of other things.
So I want have separate controller/model/view/layout for each tab and also for left side's myGroups.
What is the best way to approach this.
I appreciate if you give me some code structure too.
Thank you very much.
Alex
You could use the the Action view-helper in your layout for each or your left and right bars. But the downside to this is that you incur three full server calls (complete with bootstrap and dispatch cycle) to render a single page. I consider that to be a pretty significant downside, especially if each bar needs its own database connection.
An alternative approach is to use front-controller plugins for your left and right bars. Register them at bootstrap, give them a postDispatch() hook which accesses/generates whatever data they need and places that data into the layout/view. Then your layout renders the content without needing to know how it got there.
If you use the 'action view-helper' suggested by David, you could always ajax these in for better UX - therefore the user can read what has currently been loaded, while waiting for the rest of the page.

Resources