未捕获类型错误:未定义不是一个函数Rails3中/骨干网/ JS [英] Uncaught TypeError: undefined is not a function rails3/backbone/js

查看:199
本文介绍了未捕获类型错误:未定义不是一个函数Rails3中/骨干网/ JS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始钻研JavaScript来使项目更加敏感,我通过一个例子Backbone.js的工作。

I just started delving into javascript to make project more responsive and I am working through a backbone.js example.

我复制<一个href=\"http://www.jamesyu.org/2011/01/27/cloudedit-a-backbone-js-tutorial-by-example/\">http://www.jamesyu.org/2011/01/27/cloudedit-a-backbone-js-tutorial-by-example/在一个新的Rails 3的项目。

I've replicated http://www.jamesyu.org/2011/01/27/cloudedit-a-backbone-js-tutorial-by-example/ in a new Rails 3 project.

我运行该项目,然后转到主页....还有就是/#,别无其他的链接出现。展望JS控制台我得到两个脚本错误:application.js中和Backbone.js的

I run the project and go to the home page .... and there is a link there to /# and nothing else. Looking into the js console I get errors on two scripts: application.js and backbone.js

这(Backbone.js的)

This (backbone.js)

backbone-min-0-3-3.js:8Uncaught TypeError: Cannot call method 'extend' of undefined

和这个(application.js中):

and this (application.js):

var App = {
        Views: {},
        Controllers: {},
        Collections: {},
        init: function() {

        new App.Controllers.Fffforms();
**error message ---> application.js:9Uncaught TypeError: undefined is not a function**
            Backbone.history.start();
        }
};

作为新的JS,这并不完全意义并没有什么,我抬头一看已经在短期内一切有益的。

Being new to js, this doesn't exactly make sense and nothing I've looked up has been all that helpful in the short term.

谁能告诉我,究竟这些错误将表明,我怎么能去跟进?一切检查出比较资源
https://github.com/jamesyu/CloudEdit ,但我从一个新的Rails 3项目(而不是回购的克隆复制)不完全工作。

Can anyone tell me what exactly these errors would indicate and how I can go about following up? Everything checks out comparing the resources in https://github.com/jamesyu/CloudEdit, but my replication from a new rails 3 project (not a clone of that repo) doesn't exactly work.

任何建议AP preciated,铭记我刚刚开始学习一些JavaScript。

Any suggestions appreciated, bearing in mind I've just embarked on learning some javascript.

编辑:

通过建议下,我去了Jammit宝石实际添加并配置它来服务所有的JS脚本,默认的Rails都没有。现在所有的脚本是要在浏览器(包括控制器)。不幸的是,这并没有解决原来的问题,只给负载更多的错误,从App INIT这也是本在Chrome JS控制台流:

By suggestion, I went and actually added in the Jammit gem and configured it to serve all the js scripts, which the default Rails all was not. Now all the scripts are going to the browser (controller included). Unfortunately, this doesn't solve the original issue, only giving more errors on load, flowing from the App init which is this in the chrome js console:

Uncaught TypeError: undefined is not a function
App.initapplication.js:9
(anonymous function):3000/#new:32
d.extend._Deferred.f.resolveWithjquery.min.js:16
d.d.extend.readyjquery.min.js:16
d.c.addEventListener.yjquery.min.js:16

由于我只是复制,现在,必须有一些小细节忽略超越我大气压是preventing从应用程序启动正常。

Given I'm just copying right now, there must be some small overlooked detail beyond me atm that is preventing App from initiating properly.

推荐答案

这听起来像你不包括持有 App.Controllers.Fffforms 的声明文件。请确保您包括文件某处你,你包括的application.js之前,code。

It sounds like you are not including the file that holds the declaration of App.Controllers.Fffforms. Make sure that you are including that file somewhere in you code prior to where you include application.js.

这篇关于未捕获类型错误:未定义不是一个函数Rails3中/骨干网/ JS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆