我正在开发一个日历风格的骨干应用程序,但我对它很新.我现在已经对这个问题进行了超过12小时的研究,但仍然无法使我的模板填充JSON数据.
这是我今天写的一些代码:
模型
var CalendarDay = Backbone.Model.extend({
defaults: function () {
return {
title: "No days for this event",
done: false
};
},
initialize: function () {}
});
var calendarItem = new CalendarDay({
urlRoot: URL
});
Run Code Online (Sandbox Code Playgroud)
采集
var Calendar = Backbone.Collection.extend({
model: CalendarDay,
url: URL
});
Run Code Online (Sandbox Code Playgroud)
视图
var CalendarView = Backbone.View.extend({
template: _.template($('#days').html()),
initialize: function () {
this.collection = new Calendar();
this.collection.fetch();
this.collection.bind("reset", this.render, this);
this.loadTimes();
},
render: function () {
var JSON = this.collection.toJSON();
this.$el.html(this.template(JSON));
console.log(JSON);
},
listDays: function …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用choosen.js生成的选择下拉列表在表单上设置验证
这是我的代码:
$('.chzn-single').bind("change", function(){
$myform.validate().element($(this));
});
Run Code Online (Sandbox Code Playgroud)
我认为这样的事情可行,但我没有取得任何成功.有什么想法?
谢谢