Jelajahi Sumber

HUE-845 [fb] History is broken

Fixed hashchange for URLs with no hash
Enrico Berti 13 tahun lalu
induk
melakukan
f2a5b8643e

+ 8 - 1
apps/filebrowser/src/filebrowser/templates/listdir_components.mako

@@ -445,9 +445,16 @@ from django.utils.translation import ugettext as _
             });
 
             $(window).bind("hashchange", function() {
+                var target = "";
                 var hash = window.location.hash.substring(1);
                 if (hash != null && hash != "") {
-                    viewModel.targetPath("${url('filebrowser.views.view', path=urlencode('/'))}" + hash.substring(1));
+                    target = "${url('filebrowser.views.view', path=urlencode('/'))}" + hash.substring(1);
+                }
+                if (window.location.href.indexOf("#") == -1){
+                    target = "${current_request_path}";
+                }
+                if (target != ""){
+                    viewModel.targetPath(target);
                     viewModel.retrieveData();
                 }
             });