Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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
like image 731
chrmod Avatar asked Aug 09 '13 08:08

chrmod


1 Answers

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

like image 183
chrmod Avatar answered Sep 22 '22 10:09

chrmod