2014-11-22 3 views
1

간단한 Ember-Rails 앱을 얻으려고하고 있으며 모든 것이 잘 렌더링 된 것처럼 보이지만 뒤로 버튼은 렌더링 된 모든 요소를 ​​완전히 제거합니다. 오류가 없습니다.엠버 레일 백 버튼은 중첩 된 경로가없는 경우에도 템플릿을 렌더링하지 않습니다.

Ember는 '부모'템플릿이 이미 렌더링되었으므로 렌더링을 다시 렌더링하지 않으므로이 문제가 발생합니다. 내 응용 프로그램에서는 먼저 각 게시물에 대한 링크가있는 '게시물'목록을 렌더링합니다. 각 링크는 문제의 게시물을 열어 렌더링 된 '게시물'페이지를 대체해야합니다. 이렇게하면 다시 버튼을 클릭하면 재미있는 일을합니다. 인덱스 페이지를 렌더링 한 다음 응용 프로그램 템플릿의 모든 항목 (인덱스 등 포함)을 모두 제거합니다. 레일 내가 그 파일 핸들 템플릿에 컴파일 .hbs 생각

<!DOCTYPE html> 
<html> 
<head> 
    <title>Slimgur</title> 
    <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> 
    <%= stylesheet_link_tag 'bootstrap', media: 'all', 'data-turbolinks-track' => true %> 
    <%= stylesheet_link_tag 'bootstrap-theme', media: 'all', 'data-turbolinks-track' => true %> 
    <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> 
    <%= csrf_meta_tags %> 
</head> 
<body> 
<%= yield %> 

<div class='container'> 
    <div id="ember-app"> 
    </div> 
</div> 

</body> 
</html> 

//This is the page that is rendered by rails. 
<h1>Static#index</h1> 
<p>Find me in app/views/static/index.html.erb</p> 

/* Application.js file. After all require statements. */ 
App = Ember.Application.create({rootElement: '#ember-app'}); 

/* Router.js */ 
// -------------------------- 
App.Router.map(function() { 
    this.resource('posts'); 
    this.resource('post', { path: 'posts/:id' }); 
}) 

/* Application.hbs. */ 
// -------------------------- 
<header> 
    <article> 
     <div class="logo"> 
      <h1> 
       <a href="#">App</a> 
      </h1> 
     </div> 
</article> 
</header> 

{{!-- This is intended to render all Ember Templates. --}} 
<section id="main"> 
    {{{outlet}}} 
</section> 

<footer> 
    <p> Testing Footer one two three </p> 
</footer> 

/* posts.hbs */ 
// -------------------------- 
<article id="posts"> 
    <h1>Posts</h1> 

     <ul> 
      {{#each post in model}} 
       <li>{{#link-to 'post' post}}{{post.title}}{{/link-to}}</li> 
      {{/each}} 
     </ul> 
</article> 

{{outlet}} 

/* post.hbs*/ 
// -------------------------- 
<h2>{{title}}</h2> 

/* Ember Routes: */ 
// -------------------------- 
App.PostsRoute = Ember.Route.extend({ 
    model: function(){ 
     return this.store.find('post'); 
    }, 
}) 

App.PostRoute = Ember.Route.extend({ 
    model: function(params){ 
     return this.store.find('post', params.id); 
    }, 
}) 

을 application.html.erb,

첫째 : 여기

코드 관련 조각입니다.

+0

[Ember.js with Rails4 : 브라우저 다시 버튼 충돌 엠버 응용 프로그램] 가능한 복제본 (http://stackoverflow.com/questions/18142401/ember-js-with-rails4-browser-back-button-crash-ember) -신청) – Chris

답변

0

음, 결국 터보 링크를 제거했습니다. 나는 아직도 그렇게하는 것에 대해 조금 확신 할 수는 없지만 어떤 식 으로든 내 응용을 방해하지 않는 것처럼 보인다.

그렇게하려면 turbolinks gem, application.js의 'require turbolinks'행 및 application.html.erb의 turbolink 태그를 제거해야합니다.

나는 내가 보지 못했던 것을 망쳐 놓지 않았 으면하고 바라는 나의 손가락을 횡단하고있다.