vendredi 3 juin 2016

Ember Render Different View for First Item in Index Model

I am still pretty new to Ember and trying to get my head around it. What I am trying to do is return my model to the index view, which contains, say, 5 array entries. I want my Index view to take the first, to render a separate, featured, view then take the remaining four and render them as a list. However, I have not had any luck with ...like I have read. Here is my code currently:

Index.html

<script type="text/x-handlebars" data-template-name="index">
        <section class="featured-section">
            <div class="content-container">
                
            </div>
        </section>
        <section class="content-container main">
            
            <article>
                <div class="img">
                    <img src="lib/img/preview/" alt="">
                </div>
                <div class="content">
                    <h2> ()</h2>
                    <p>}</p>
                </div>
            </article>
            
        </section>
    </script>

    <script type="text/x-handlebars" data-template-name="featured">
        
        
        <article class="featured">
            <div class="img">
                <img src="lib/img/feature/" alt="">
            </div>
            <div class="content">
                <h2></h2>
                <p>}</p>
            </div>
        </article>
        
        
    </script>

Routes.js

var projects = [];
App.IndexRoute = Ember.Route.extend({
        model: function(params) {
            var url = 'lib/js/data/data.json';

            return Ember.$.getJSON(url).then(function(data) {
                projects = data;

                return projects.reverse();
            });
        }
    });




Aucun commentaire:

Enregistrer un commentaire