gpt4 book ai didi

backbone.js - BackboneJS单击事件未触发

转载 作者:行者123 更新时间:2023-12-03 05:32:41 26 4
gpt4 key购买 nike

我知道以前有人问过这个问题,但我找不到正确的答案,尽管它很简单:

我的 HTML 模板中有这个:

<div id="vid"></div>
<button class="mdk-close">x</button>

这在我看来:
function (App, Backbone, ArtistVideos, Artistimg, Artistname) {

var ArtistVideoPopup = App.module();

ArtistVideoPopup.View = Backbone.View.extend({
template: 'artistYoutubeVideo',
events: {
"click .mdk-close": "test"
},
test: function() {
alert('dasdasas')
},
beforeRender: function() {
var artistimgCollection = new Artistimg.ArtistimgCollection();
artistimgCollection.artist_id = this.artist_id;
this.insertView('.artistImage', new Artistimg.View({collection: artistimgCollection}));
artistimgCollection.fetch();

var artistnameCollection = new Artistname.ArtistnameCollection();
artistnameCollection.artist_id = this.artist_id;
this.insertView('.artistName', new Artistname.View({collection: artistnameCollection}));
artistnameCollection.fetch();

var artistvideosModel = new ArtistVideos.ArtistVideosModel();
artistvideosModel.artist_id = this.artist_id;
artistvideosModel.video_youtube_id = this.video_youtube_id;
artistvideosModel.fetch();
},

afterRender: function() {

$('ul.acmenu li a.selected').removeClass('selected');
$('ul.acmenu li a.artistVideos').addClass('selected');

var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

var player;
window.onYouTubeIframeAPIReady = _.bind(function() {
player = new YT.Player('vid', {
height: '480',
width: '853',
videoId: this.video_youtube_id,
events: {
onReady: onPlayerReady,
onStateChange: onPlayerStateChange
}
})
}, this);

function onPlayerReady(event) {
event.target.playVideo();
}

var done = false;
function onPlayerStateChange(event) {
// if (event.data == YT.PlayerState.PLAYING && !done) {
// setTimeout(stopVideo, 6000);
// done = true;
// }
}
function stopVideo() {
player.stopVideo();
}


},



});

return ArtistVideoPopup;
}

但事件根本没有触发。有谁知道可能是什么问题?

提前致谢...

最佳答案

events在您看来,只绑定(bind)到 view.el 内的元素

关于backbone.js - BackboneJS单击事件未触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23514291/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com