С событием выше в позвоночнике я не могу определить ориентацию. Это не работает. Есть ли альтернатива этому? Связать событие или что-то еще? Или что-то не так в моем коде?Изменение ориентации событий не работает в магистрали
var HomeView = Backbone.View.extend({
template: Handlebars.compile(template),
events: {
"click .log_out": "log_out",
"click .prove": "prove",
"orientationchange": "onOrientationChange"
},
initialize: function() {
console.log("inhomeview");
this.render();
},
render: function() {
//var context = JSON.parse(JSON.stringify(this.model));//eliminare
var context = this.model;
var html = this.template(context);
console.log(html);
$('#pagina').empty();
$('#pagina').append(this.$el.html(html));
return this;
},
onOrientationChange: function() {
if (window.orientation === 90 || window.orientation === -90) {
alert('you are in landscape');
}
}
});
см http://stackoverflow.com/questions/1649086/detect-rotation-of-android-phone-in-the-browser- with-javascript –
'onorientationchange' - свойство объекта окна. Теперь вы пытаетесь применить его к Backbone View. – zvona