javascript - history.back in backbone seems don't work -
i'm trying use windows.history.back() nothing happens. when event call history.back appear few second or less menu of previous page.
below view function called:
var landscapeview = backbone.view.extend({ template: handlebars.compile(template), events: { }, initialize: function() { this.geolocation(); $(window).on('orientationchange', this.onorientationchange); }, /* render: function() { //var context = json.parse(json.stringify(this.model));//eliminare //var context=this.model; var html =this.template(); this.$el.html(html); $('#pagina').empty(); $('#pagina').append(this.$el.html(html)); return this; },*/ geolocation:function(){ navigator.geolocation.getcurrentposition(win); function win(pos){ console.log("gps"); /* var el='<div>'+ pos.coords.latitude+'</div>'; el+='<div>'+ pos.coords.longitude+'</div>'; el+='<div>'+ pos.timestamp+'</div>'; $('#pagina').html(el);*/ var lat=pos.coords.latitude; var lon=pos.coords.longitude; var options={ center:new google.maps.latlng(lat,lon), zoom:15, maptypeid: google.maps.maptypeid.roadmap }; var html=$('#pagina'); console.log(html); var map= new google.maps.map(document.getelementbyid('pagina'),options); console.log(map); }; }, onorientationchange: function() { if(window.orientation === 0) { window.history.back(); } } }); return landscapeview; });
and here view previous history.back can't re-call:
var homeview = backbone.view.extend({ template: handlebars.compile(template), events: { "click .log_out":"log_out", "click .prove":"prove", }, initialize: function() { console.log("inhomeview"); this.render(); $(window).on('orientationchange', this.onorientationchange); }, render: function() { //var context = json.parse(json.stringify(this.model));//eliminare var context=this.model; var html =this.template(context); console.log(html); this.$el.html(html); $('#pagina').empty(); $('#pagina').append(this.$el.html(html)); return this; }, onorientationchange: function() { if(window.orientation === 90 || window.orientation === -90) { new landscapeview(); } }, log_out:function(){ console.log("logout"); parse.user.logout(); // new appview;//errore undefined not function window.location='index.html' ;//mettere una new appview ma da errore!!! }, prove:function(){ navigator.geolocation.getcurrentposition(win); function win(pos){ console.log("gps"); /* var el='<div>'+ pos.coords.latitude+'</div>'; el+='<div>'+ pos.coords.longitude+'</div>'; el+='<div>'+ pos.timestamp+'</div>'; $('#pagina').html(el);*/ var lat=pos.coords.latitude; var lon=pos.coords.longitude; var options={ center:new google.maps.latlng(lat,lon), zoom:15, maptypeid: google.maps.maptypeid.roadmap }; var html=$('#pagina'); console.log(html); var map= new google.maps.map(document.getelementbyid('pagina'),options); console.log(map); }; } }); return homeview; });
and router:
var approuter = backbone.router.extend({ routes: { "": "home", "user/:objectid":"prova", "settings":"settings",//mettere id dell utente loggato "friends":"friends", "mailbox":"mailbox" }, home: function() { console.log("inrouter"); new appview(); }, settings: function(){ console.log("settings"); var view=new settingsview(); $('#pagina').html(view.render().el); }, friends: function(){ console.log("friends"); var view=new friendsview(); $('#pagina').html(view.render().el); } , mailbox: function(){ console.log("mailbox"); } }); return approuter; });
and here main history starts:
document.addeventlistener("deviceready", run, false); run(); function run() { var sync = backbone.sync; backbone.sync = function(method, model, options) { options.beforesend = function (xhr) { xhr.setrequestheader('x-parse-application-id', 'qs0klmx5h9lflg**yhm9eepits3vmk'); xhr.setrequestheader('x-parse-rest-api-key', 'nh3eouo9g**vbf2gmhckjifit1gm'); }; sync(method, model, options); }, app = new approuter(); backbone.history.start(); parse.$ = jquery; parse.initialize("qs0klmx5h9l****tyhm9eepits3vmk", "h4m*****agobqlwzrdw8irpdpf9qln7duy"); }
Comments
Post a Comment