In my application.hbs file I have an application wide nav bar.
<div class="row nav">
<div class="large-12 colummns">
<ul class="inline-list top-nav">
<li><h6>{{#linkTo "about.philosophy"}}ABOUT{{/linkTo}}</h6></li>
<li><h6>//</h6></li>
<li><h6>CONDITIONS</h6></li>
<li><h6>//</h6></li>
<li><h6>PROGRAMS</h6><li>
<li><h6>//</h6></li>
<li><h6>TESTIMONIALS</h6></li>
</ul>
</div>
</div>
<div class="row subnav">
<div class="large-12 colummns">
{{#if renderAboutSubNav}}
{{render 'about/subnav'}}
{{/if}}
</div>
</div>
{{outlet}}
subnav.hbs:
<ul class="inline-list subnav-list">
<li class="subnav-item">{{#linkTo "about.philosophy"}}philosophy{{/linkTo}}</li>
<li class="subnav-item">//</li>
<li class="subnav-item">{{#linkTo "about.leadership"}}leadership{{/linkTo}}</li>
<li class="subnav-item">//</li>
<li class="subnav-item">staff</li>
</ul>
The ABOUT link, when clicked, displays a subnav -- displayed whenever the url contains 'about'. In that subnav are about subpages -- philosophy, leadership, staff. Philosophy is actually the index page of the about section, which is why I am linking ABOUT to about.philosophy:
{{#linkTo "about.philosophy"}}ABOUT{{/linkTo}}
When I click ABOUT, the ember app renders /about/philosophy as it is supposed to, and the ABOUT link and philosophy link in the subnav are set to active.
However, when I click 'Leadership' the leadership link on the subnav is active but not the ABOUT link in the main nav, even though the url reads /about/leadership.
I don't understand why it is doing this.
My router looks like this:
Ew.Router.reopen(location: 'history')
Ew.Router.map ->
#.resource "about", ->
#.route "philosophy"
#.route "leadership"
#.resource "staff"
#.route "conditions"
#.route "programs"
#.route "testimonials"
about.hbs:
<div class="row about-bg">
<div class="large-12 columns">
<div class="row">
<h1 class="about-phil">Eskridge & White</h1>
</div>
</div>
</div>
<div class="row philosophy-content">
<div class="large-9 columns about-us">
{{outlet}}
</div>
</div>
<div class="large-3 columns sidebar">
{{partial 'sidebar'}}
</div>
</div>
The problem here is you are linking to about.philosophy, so when you navigate to about.leadership active class won't be applied.
So make your link-to to point about route,
{{#link-to "about"}}ABOUT{{/link-to}}
And from your about.index route, redirect to about.philosophy route,
so that active class will be always applied to about's link-to whenever you are in the child of about route.
A bin for your case.
Related
Using OOTB SXA, I am trying to render selected items from Multilist with Search.
The data renders, but with everything nested in a single <li> broken into <div>'s
Among other things, I've tried using and Item Query (re: https://ggullentops.blogspot.com/2017/04/sitecore-sxa-pagelist-item-query.html), but didn't have any success.
Q: What is the correct way to render my items as individual <li>'s?
Current Results displayed:
<main>
<div id="content" class="container">
<div class="component page-list col-12">
<div class="component-content">
<ul class="items">
<li class="item">
<div class="field-first-name">Stephen</div>
<div class="field-last-name">King</div>
<div class="field-first-name">Gregory</div>
<div class="field-last-name">Mertens</div>
<div class="field-first-name">Penny</div>
<div class="field-last-name">Mertens</div>
</li>
</ul>
</div>
</div>
</div>
</main>
Multi Select List Data Source:
List Item:
Control Properties:
Rendering Variant
I'm trying to access data two times in my template, once on a list view, and once in a modal view. Upon clicking on the image, the modal will display a lot of the same data, just blown up. I'm having issues. The modal seems to be taking the last set of data, even though it's nested in the each statement. Any ideas? Here's my code...
<div class="row">
{{#each model.products as |product|}}
<div class="col-xs-12 col-sm-6 col-md-4">
<div class="shopify-grid-wrapper">
<div id="#image-wrapper" class="image-wrapper" {{action 'openModal'}}>
<div class="img-overlay">
<p>
Click for More Details
</p>
</div>
{{#each product.images as |image|}}
<img src= {{image.src}} />
{{/each}}
</div>
<div class="description-wrapper">
<span><p>{{product.title}}</p></span>
<p>
{{product.productType}}
</p>
<p>
{{product.tags}}
</p>
</div>
</div>
</div>
{{#if shopifyModal}}
{{#liquid-wormhole class="fullscreen-modal" }}
<div class="left-side">
{{selectedProduct.title}}
</div>
<div class="right-side">
{{buy-button product=product.attrs open="openCart"}}
<div class="Cart {{if model.isCartOpen "Cart--open"}}">
{{shopify-cart close="closeCart"}}
</div>
<p {{action 'closeModal'}}>
Close
</p>
</div>
{{/liquid-wormhole}}
{{/if}}
{{/each}}
</div>
The problem was answered in the comments, but I'm adding this here in case someone finds it.
When looping over a collection in a template, if you have an action inside that loop, you must pass some information to the action handler if you expect the "current" item to be processed by the action handler, like this:
{{action 'openModal' product}}
I have normal, basic ember-cli project.
This is my application.hbs:
<div class="container-fluid">
<div class="row">
<div class="col-sm-3 col-md-2 sidebar">
{{render 'sidebar'}}
</div>
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
{{outlet}}
</div>
</div>
</div>
This is my post.hbs:
{{#each model as |post|}}
{{post.text}}
{{/each}}
This is my sidebar.hbs:
<ul class="nav nav-sidebar">
{{#each model.posts as |post|}}
<li>{{#link-to author}}{{post.author.name}}{{/link-to}}</li>
{{/each}}
</ul>
and everything else is standard.
How to make work {{render 'sidebar'}} with just the title of my categories?
Now it shows nothing.
Updated the answer above me.
// application.hbs
<div class="container-fluid">
<div class="row">
<div class="col-sm-3 col-md-2 sidebar">
{{side-bar}}
</div>
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
{{outlet}}
</div>
</div>
</div>
// templates/components/side-bar.hbs
<ul class="nav nav-sidebar">
{{#each posts as |post|}}
<li>{{#link-to author}}{{post.author.name}}{{/link-to}}</li>
{{/each}}
</ul>
// components/side-bar.js
// This triggers once the component is called out {{side-bar}}.
init: function() {
// You're extending ember component class here
// This class has its own init function if u dont call
// _super() it means that the component has not yet been
// Initialised and component's not working.
this._super();
// Use your queries or what ever u need here
// e.g query('posts', { user: 1 })
this.set('posts', this.get('store').find(x));
}
I'm not sure why the render helper was not deprecated in Ember 1.13 and removed in 2.0, but you really shouldn't use it any more. The render helper uses a view and a controller that is not at the top level. Views have been removed in 2.0, and controllers not at the top level are deprecated.
Make your sidebar a component.
// application.hbs
<div class="container-fluid">
<div class="row">
<div class="col-sm-3 col-md-2 sidebar">
{{side-bar model=model}}
</div>
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
{{outlet}}
</div>
</div>
</div>
// templates/components/side-bar.hbs
<ul class="nav nav-sidebar">
{{#each model.posts as |post|}}
<li>{{#link-to author}}{{post.author.name}}{{/link-to}}</li>
{{/each}}
</ul>
Today , I just start learning ember.js. I tried one sample application.
Search the result and it will show the list. Click on the link and it will show the result at right sidebar. It's working fine.
However, I want to show home template at first.
When I tried with {{outlet name}} , it can show the home template however it is not working when I click on link. So, is there any way to show default outlet ?
I found about default outlet at here . However, it need to remove my data-templte-name to show default outlet. I don't want to remove the data-template-name.
Current template is like following.
<script type="text/x-handlebars" data-template-name="dictionary">
<div id="left">
<header>
<div id="topheader">
<img src="images/logo.jpg" class="logo">
<i id="search-icon"> </i>
{{input type="text" id="query" placeholder="Search" value=query
action="query"}}
</div>
</header>
<div id="results">
{{#each results}}
{{#link-to "detail" this}}
<section>
<div class='detail'>
<div class='word'>{{Word}}</div>
<div class='state'>{{state}}</div>
<div class='def'>{{def}}</div>
</div>
</section>
{{/link-to}}
{{/each}}
</div>
<footer>
<div id="bottom">
<a href="#" class='btn'>Login</a>
<a href="#" class='btn add'>Add</a>
</div>
</footer>
</div>
<div id="right">
{{outlet}}
</div>
</script>
<script type="text/x-handlebars" id="detail">
<div id="details">
<div class='word'>{{Word}}</div>
<div class='state'>{{state}}</div>
<div class='def'>{{def}}</div>
</div>
<div id="discuss">
</div>
</script>
<script type="text/x-handlebars" id="home">
<div id="homeScreen">
Sample home screen
</div>
</script>
The root template to be rendered is the application template (associated with the root/application level). An empty id/data-template-name is assumed to be the application template. If you want to use a different template for the application root you can create the application view and specify the templateName.
App.ApplicationView = Ember.View.extend({
templateName: 'foo'
});
http://emberjs.jsbin.com/EZocURAR/1/edit
my problem is that while on a desktop I like having the menu first, and then the logo in the far right corner. Currently when I shrink the template to a mobile version, the logo goes under the menu which is not satisfactory. I would like to have it before the menu. I've tried using push/pull with no success.
Is it even possible to have the logo on top of the template when in mobile view?
Here is my code...
<div class="container" style="margin-top: 15px;">
<div class="row">
<div class="ten columns mobile-four">
<nav>
<ul>
<li>link</li>
<li>link</li>
<li>link</li>
<li>link</li>
<li>link</li>
<li>link</li>
</ul>
</nav>
</div>
<div class="two columns mobile-four">
<img src="images/logo.png" alt="logo"/>
</div>
</div>
</div>
So first you can do away with the mobile-four class, it doesn't do anything (unless its custom to you). Looking at the documentation there is a mobile-[one two three], four would be the equivalent to leaving it off.
To fix the problem, simply apply a source ordering class, like so:
<div class="container" style="margin-top: 15px;">
<div class="row">
<div class="two columns push-ten">
<a href="index.php">
<img src="images/logo.png" alt="logo" /></a>
</div>
<div class="ten columns pull-two">
<nav>
<ul>
<li>link</li>
<li>link</li>
<li>link</li>
<li>link</li>
<li>link</li>
<li>link</li>
</ul>
</nav>
</div>
</div>
</div>
Push and pull will correctly order the Menu first and Logo second. Push and pull are ignored on mobile, meaning your logo will stack above the menu on mobile.
Desktop:
[Menu][Logo]
Mobile
[Logo]
[Menu]
Docs:
http://foundation.zurb.com/docs/grid.php