With the event above in backbone I can't detect the orientation. It doesn't work.Are there any alternative to that?By bind an event or something else?Or something is wrong in my code?
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');
}
}
});