骨干出错

时间:2013-04-29 20:13:57

标签: javascript backbone.js parse-platform

我正在通过骨干开发应用程序,但现在出现同样的错误:

  

Uncaught TypeError: Object function (){ parent.apply(this, arguments); } has no method 'match'

当我添加了新的注册视图时,这个错误就开始出现了:

define(["jQuery", "underscore", "Backbone", "Handlebars", "models/person", "views/signupview", "text!templates/loginview.html"], function ($, _, Backbone, Handlebars, Signupview, template) {
    var LoginView = Backbone.View.extend({
        template: Handlebars.compile(template),
        events: {
            "click .sign_up": "signUp_manual"
        },
        initialize: function () {
            this.render();
        },
        render: function () {
            var html = this.template();
            $('#pagina').html(this.$el.html(html)); //appendo ad el);
            return this;
        },
        signUp_manual: function () {
            console.log("signup");
            new Signupview();
        }
        //inserire funzione per log-in
    });
    return LoginView;
});

这里是Signupview:

define(["jQuery", "underscore", "Backbone", "Handlebars", "text!templates/signup.html"], function ($, _, Backbone, Handlebars, template) {
    var Signupview = Backbone.View.extend({
        template: Handlebars.compile(template),
        events: {},
        initialize: function () {
            this.render();
        },
        render: function () {
            var html = this.template();
            $('#pagina').html(this.$el.html(html)); //appendo ad el);
            return this;
        }
    });
    return Signupview;
});

1 个答案:

答案 0 :(得分:1)

问题来自这条线,

define(["jQuery", "underscore", "Backbone", "Handlebars", "models/person", "views/signupview", "text!templates/loginview.html"], function ($, _, Backbone, Handlebars, PersonModel, Signupview, template) {
    //your code
});

你错过了回调函数中的PersonModel参数