From 8a16b15d29f88ef453f7f5e63642f9bd310ab933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20M=C3=BCller?= Date: Wed, 30 Apr 2014 17:17:15 +0200 Subject: [PATCH] back knopf --- app/webroot/js/dreamjob.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/webroot/js/dreamjob.js b/app/webroot/js/dreamjob.js index d61fbd5..ceec53d 100755 --- a/app/webroot/js/dreamjob.js +++ b/app/webroot/js/dreamjob.js @@ -10,6 +10,13 @@ ajaxStart: function() { $body.addClass("loading"); }, ajaxStop: function() { $body.removeClass("loading"); } }); + $(window).bind('popstate',function(evt){ + console.log(evt.target.pageurl); + console.log(evt); + if(evt.originalEvent.state !== null) { + load(location.href,{'history':false},false); + } + }); $("#popup").modal({'remote':false,'show':false}); $("#popup").on('show.bs.modal',function(e){ $.ajax({url:$(e.relatedTarget).attr("href"),success:function(data){ @@ -174,19 +181,22 @@ data = {}; typemethode = "GET"; back = false; + history = true; if(conf['data']) data = conf['data']; if(conf['type']) typemethode = conf['type']; if(conf['back'] && conf['back'].indexOf("logout")== -1 && conf['back'].indexOf("login")== -1 ) back = conf['back']; + if(conf['history']) + history = conf['history']; //e.preventDefault(); /* if uncomment the above line, html5 nonsupported browers won't change the url but will display the ajax content; if commented, html5 nonsupported browers will reload the page to the specified link. */ $.ajax({url:pageurl,data:data,type:typemethode,success:function(data){setContent(data,back,tab);} ,error:function(data){setContentError(data,back,tab);}}); - if(pageurl!=window.location){ + if(history && pageurl!=window.location){ window.history.pushState({path:pageurl},'',pageurl); } };