在主干中发生上述事件时,我无法检测到方向。它不起作用。是否有任何替代方法?通过绑定事件或其他方式?或者我的代码有问题?
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');
}
}
});