How to do it? I searched SO, find one similar result, but it doesn't work.
Here's my code:
var Player = Backbone.Model.extend({
defaults: {
//some variables
},
//creating audio element
setAudio: function(ogglink, mp3link){
//code, that works
}
});
var Playlist = Backbone.Collection.extend({
model: Player
});
var MyPlaylist = new Playlist([
//some songs here
]);
var OneSongView = Backbone.View.extend({
//added some 'template' and 'el' code
initialize: function () {
this.model.bind("change", this.render, this);
},
render: function (eventName) {
$(this.el).html(this.template(this.model.toJSON()));
this.model.setAudio(this.model.get("ogglink"), this.model.get("mp3link"));
return this;
},
events: {
//declaration of some events
},
//event functions
});
var AppRouter = Backbone.Router.extend({
//router code
});
var app = new AppRouter();
Backbone.history.start();
If i add in events something like "timeupdate": "somefunc", it'll not work, if i add code like here, i'll hsve errors :(