Ember.js with Rails4: browser back button crash ember application
Asked Answered
P

1

7

EDIT: the issue is solved. Removing turbolinks is all you need to do.

With a Rails4 application the use ember-rails 0.13.0 we have a problem of not functional browser back button. Each time while getting back to previous route using the back button the application is crashing with such errors:

on Firefox 24.0a2:

TypeError: Class.PrototypeMixin.applyPartial is not a function @ http://localhost:3000/assets/ember.js?body=1:11933

on Chromium 28:

Uncaught Error: jquery-ujs has already been loaded! jquery.js?body=1:517I 
DEBUG: ------------------------------- ember.js?body=1:364
DEBUG: Ember.VERSION : 1.0.0-rc.6.1 ember.js?body=1:364
DEBUG: Handlebars.VERSION : 1.0.0 ember.js?body=1:364
DEBUG: jQuery.VERSION : 1.10.2 ember.js?body=1:364
DEBUG: ------------------------------- 

It looks like the whole application stack is loaded again that ends with not functional code base. Anyway the same application works perfectly good with Rails3.

Reports from other people having problems with ember.js together with turbolinks:

Cannot perform operations on a Metamorph that is not in the DOM
Preponderate answered 9/8, 2013 at 8:0 Comment(0)
P
7

After some debugging we had noticed those are turbolinks causing the problem. Using backbutton triggered turbolinks which were causing strange effects with the ember.js application like reloading all javascripts and thus overriding the state of app.

Removing turbolinks done the job. Here is a useful link how to do it: http://blog.steveklabnik.com/posts/2013-06-25-removing-turbolinks-from-rails-4

Preponderate answered 9/8, 2013 at 8:0 Comment(2)
Turbolinks also causes "Cannot perform operations on a Metamorph that is not in the DOM" errors in Ember - again, went away when I kicked Turbolinks to the curb.Lanielanier
@Lanielanier thanks for report. I've attached it to original question as it may help someone.Preponderate

© 2022 - 2024 — McMap. All rights reserved.