브라우저의 뒤로 버튼을 클릭하면 현재보기의 deleteMarker
함수를 호출하고 싶습니다. 나는 비슷한 질문을했지만 아무도 나를 도울 수 없었다.백본 : 브라우저의 뒤로 버튼을 클릭하면보기의 기능을 호출합니다.
deleteMarker
호출 할
현재보기 : 검사는 history.back
ev.views.Evento = Backbone.View.extend({
map: 'null',
initialize: function(id){
.....
},
// function that will call
deleteMarker: function(){
this.marker.remove();
},
render: function(id){
.....
}
});
이
var ev = new Application();
ev.Router = Backbone.Router.extend({
routes: {
"": "home",
"evento/:id" : "evento"
},
home: function(){
setTimeout(function(){
$('#rightcolumn').html(new ev.views.Home_Eventos(ev.shell.map).el);
}, 0);
},
evento: function(id){
$('#rightcolumn').html(new ev.views.Evento(id).el);
}
});
$(document).on('ready', function() {
ev.templateLoader.load(['shell', 'home_list_eventos', 'evento'], function() {
ev.shell = new ev.views.Shell({el: "#shell"});
ev.router = new ev.Router();
Backbone.history.start();
});
});
ev.Router.home에서 왜 milliseconds 매개 변수가 0 인'setTimeout'을 호출하고 있습니까? 이것이 저에게'setTimeout'의 요점을 무력화시킨 것 같습니다. – 76484
이 패턴에 대한 흥미로운 토론을 검색하여 발견했습니다. http://stackoverflow.com/questions/779379/why-is-settimeoutfn-0-sometimes-useful – 76484
http://stackoverflow.com/questions/14543245/browser- back-button-handling http://stackoverflow.com/questions/25806608/how-to-detect-browser-back-button-event-cross-browser 그냥'Router'에서 이벤트를 듣고 Backbone 이벤트를 트리거합니다. 보기는 그것의 일을 경청하고 있을지도 모른다. –