2013-11-10 143 views
0

我有以下模板:爲什麼我會顯示?

<script type="text/x-handlebars" data-template-name="projects"> 
    <div class="container-fluid"> 
     <div class="row-fluid"> 
     {{#linkTo "projects"}}Root{{/linkTo}} 
     {{#each controller}} 
      <div class="span4"> 
      {{#linkTo "projects.show" this}}{{this.name}}{{/linkTo}} 
      </div> 
     {{/each}} 
     </div> 
     {{outlet}} 
    </div> 
    </script> 

和:

<script type="text/x-handlebars" data-template-name="projects/show"> 
    <h2>Overview of {{name}}</h2> 
    </script> 

和app.js以下內容:

App = Ember.Application.create({ 
    LOG_TRANSITIONS: true 
}); 

App.Project = DS.Model.extend({ 
    name: DS.attr("string"), 
    key : DS.attr("string") 
}); 

App.Router.map(function() { 
    this.resource("projects",function() { 
    this.route("show", {path: "/:project_id"}); 
    }); 
}); 

App.IndexRoute = Ember.Route.extend({ 
    redirect: function() { 
    this.transitionTo("projects"); 
    } 
}); 

App.ProjectsRoute = Ember.Route.extend({ 
    model: function() { 
    return this.store.find("project"); 
    }, 
}) 

和下面的模型設置:

App.Store = DS.Store.extend({ 
    adapter: DS.FixtureAdapter // run with fixture data 
}); 

App.Project.FIXTURES = [ 
    { 
    id: 1, 
    name: 'Proj1', 
    key: "P1KEY" 
    }, 
    { 
    id: 2, 
    name: 'Proj2', 
    key: "P2KEY" 
    }, 
]; 

當我第一次導航到頁面時,我看到以下3個鏈接(Root,Proj1和Proj2)。由於我在索引視圖我起初,我看到:

enter image description here

然後,我點擊第一個項目,我看到:

enter image description here

而且,最後我回到指數,但項目/節目內容似乎依然存在:

enter image description here

任何人都可以解釋發生了什麼?

回答

1

當你說回到索引,你是說你點擊根鏈接?它看起來像它的作品對我說:

http://emberjs.jsbin.com/IBECuSID/1/edit

BTW,我走到灰燼數據的更新版本,所以小的變化:

App.ApplicationAdapter = DS.FixtureAdapter; 
+0

我真該死!它也適用於我,我添加了應用程序模板後...然後我刪除它,現在我的版本也可以工作。我試圖清理我的資產/瀏覽器緩存,它仍然有效。奇怪的東西:) – Geo

相關問題