我已经尝试了这个问题的大部分解决方案,但仍然无法解决它。请帮助我,伙计们。T.T我的子事件不触发,无论我如何配置它,请指导我通过它。我的父母是'dayInfo',我正在从父母调用'schedule'。但html按钮没有触发事件。
/////计划表. html/////
<a class="ic-plus-circle add"></a>
/////计划. js/////
define(function(require) {
var Backbone = require('backbone'),
User = require('models/User'),
css = require('text!views/dayInfo/schedule.css'),
tpl = require('text!views/dayInfo/schedule.html');
return Backbone.View.extend({
initialize: function(options) {
this.template = _.template(tpl);
var self = this;
return this;
},
render: function() {
var self = this;
self.$el.html(self.template());
return this;
},
events: {
'tap .add': function(e) {
console.log('success');
var self = this;
var $this = $(e.currentTarget);
console.log('tapped');
}
}
});
});
//////日信息. html/////
<div class="tab-content"></div>
//////日信息. js/////
define(function(require) {
var Backbone = require('backbone'),
ScheduleView = require('views/dayInfo/schedule'),
css = require('text!views/dayInfo/dayInfo.css'),
tpl = require('text!views/dayInfo/dayInfo.html');
return Backbone.View.extend({
id : 'dayInfo',
initialize: function(options) {
this.template = _.template(tpl);
var self = this;
return this;
},
render: function() {
var self = this;
self.$el.html(self.template());
self.$tabContent = self.$el.find('.tab-content');
self.scheduleView = new ScheduleView({date:self.date,doctor:self.doctor,appointments:self.appointments,events:self.events}).render();
self.$tabContent.html(self.scheduleView.$el);
}
});
});
我希望每当我单击按钮时控制台都会抛出“tapped”
1条答案
按热度按时间p8ekf7hl1#
没有
tap
事件,这就是它没有触发的原因。请查看MDN - Touch events以获取可用的触摸事件列表。您需要获得一个与jQuery一起工作的touch事件插件,以拥有
tap
等自定义事件