On 08/19/2011 03:25 PM, tsedovic(a)redhat.com wrote:
From: Tomas Sedovic<tsedovic(a)redhat.com>
In browsers that don't support the HTML5 History API, Backbone redirects URLs
to the hash-based format.
E.g. /deployments/1 becomes /#deployments/1
This behaviour breaks the app, because Rails render the page located at the
root path.
Since we don't use the Backbone's capabilities that require this behaviour, we
disable it for the time being.
If we want to use them later, a modification of Rails routing logic will be
required.
---
src/app/views/layouts/application.haml | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/app/views/layouts/application.haml
b/src/app/views/layouts/application.haml
index 7fa81e7..e7a8ced 100644
--- a/src/app/views/layouts/application.haml
+++ b/src/app/views/layouts/application.haml
@@ -13,14 +13,20 @@
= stylesheet_link_tag '/stylesheets/layout_ie.css'
= stylesheet_link_tag '/stylesheets/compiled/custom.css'
+ :javascript
+ window.Conductor = {}
+ window.Conductor.PATH_PREFIX = "#{root_path}"
+ // This hack prevents Backbone from switching to the #/pools/1 type URLs
+ // when the browser doesn't support the HTML5 History API.
+ window.history || (window.history = {});
+ window.history.pushState || (window.history.pushState = function(){});
+
= javascript_include_tag "jquery-1.6.1.min.js"
= javascript_include_tag "jquery.ui-1.8.1/jquery-ui-1.8.1.custom.min.js"
= javascript_include_tag "jquery.tmpl.min.js"
= javascript_include_tag "underscore-min.js"
= javascript_include_tag "backbone-min.js"
- :javascript
- window.Conductor = {}
- window.Conductor.PATH_PREFIX = "#{root_path}"
+
= javascript_include_tag "application.js"
= javascript_include_tag "yetii-min.js"
ACK