mirror of
				https://github.com/bigskysoftware/htmx.git
				synced 2025-11-04 07:24:06 +00:00 
			
		
		
		
	Lets try that again
Experimental fix for https://github.com/bigskysoftware/htmx/issues/131
This commit is contained in:
		
							parent
							
								
									947a4470de
								
							
						
					
					
						commit
						aaae399308
					
				
							
								
								
									
										10
									
								
								src/htmx.js
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								src/htmx.js
									
									
									
									
									
								
							@ -1066,12 +1066,12 @@ return (function () {
 | 
				
			|||||||
            var elt = getHistoryElement();
 | 
					            var elt = getHistoryElement();
 | 
				
			||||||
            var path = currentPathForHistory || location.pathname+location.search;
 | 
					            var path = currentPathForHistory || location.pathname+location.search;
 | 
				
			||||||
            triggerEvent(getDocument().body, "htmx:beforeHistorySave", {path:path, historyElt:elt});
 | 
					            triggerEvent(getDocument().body, "htmx:beforeHistorySave", {path:path, historyElt:elt});
 | 
				
			||||||
            if(htmx.config.historyEnabled) history.replaceState({}, getDocument().title, window.location.href);
 | 
					            if(htmx.config.historyEnabled) history.replaceState({htmx:true}, getDocument().title, window.location.href);
 | 
				
			||||||
            saveToHistoryCache(path, elt.innerHTML, getDocument().title, window.scrollY);
 | 
					            saveToHistoryCache(path, elt.innerHTML, getDocument().title, window.scrollY);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        function pushUrlIntoHistory(path) {
 | 
					        function pushUrlIntoHistory(path) {
 | 
				
			||||||
            if(htmx.config.historyEnabled)  history.pushState({}, "", path);
 | 
					            if(htmx.config.historyEnabled)  history.pushState({htmx:true}, "", path);
 | 
				
			||||||
            currentPathForHistory = path;
 | 
					            currentPathForHistory = path;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1703,8 +1703,10 @@ return (function () {
 | 
				
			|||||||
            var body = getDocument().body;
 | 
					            var body = getDocument().body;
 | 
				
			||||||
            processNode(body, true);
 | 
					            processNode(body, true);
 | 
				
			||||||
            triggerEvent(body, 'htmx:load', {});
 | 
					            triggerEvent(body, 'htmx:load', {});
 | 
				
			||||||
            window.onpopstate = function () {
 | 
					            window.onpopstate = function (event) {
 | 
				
			||||||
                restoreHistory();
 | 
					                if (event.state && event.state.htmx) {
 | 
				
			||||||
 | 
					                    restoreHistory();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
        })
 | 
					        })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user