我收到以下代码的模型未定义错误。我添加了下划线、jquery、backbone 等,但我只能使用 console.log 函数返回对象,仅适用于 jquery$
是否有其他对象没有在定义函数中返回的原因?
下面是我来自 main.js 的代码:
require.config({
paths: {
jquery: '//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.0/jquery.min',
underscore: '//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.4/underscore-min',
backbone: '//cdnjs.cloudflare.com/ajax/libs/backbone.js/1.0.0/backbone-min',
bootstrap: '//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/js/bootstrap.min',
qunit: '//cdnjs.cloudflare.com/ajax/libs/qunit/1.11.0/qunit.min',
bootstrapDatepicker: '/js/bootstrap-datepicker',
backboneValidation: '//cdnjs.cloudflare.com/ajax/libs/backbone.validation/0.7.1/backbone-validation-min'
}
});
define([
'jquery',
'underscore',
'backbone',
'bootstrap',
'qunit',
'bootstrapDatepicker',
'backboneValidation'
], function($, _, Backbone, Bootstrap, Qunit, Datepicker, backboneValidation){
$(function(){
var ReportModel = Backbone.Model.extend({
validation: {
'date.from': {
required: true,
msg: 'Please enter a from date'
},
'date.to': {
required: true,
msg: 'Please enter a to date'
}
},
initialize: function(){
console.log('test');
}
});
$('#dp3').datepicker().on('changeDate', function(e){
$('#toDate').datepicker('setStartDate', new Date(e.date.valueOf()));
});
$('#dp4').datepicker().on('changeDate', function(e){
$('#fromDate').datepicker('setEndDate', new Date(e.date.valueOf()));
});
});
});