未捕获的ReferenceError:未定义Backbone

时间:2013-11-11 14:52:41

标签: android jquery jquery-mobile backbone.js cordova

我正在建立一个使用phonegap的网站。我注意到bakcbone和jquery -jqm,在编译的应用程序中不起作用。实际上,我在日食中收到以下错误:

  

未捕获的ReferenceError:未在文件中定义Backbone:///android_asset/www/scripts/JSscript.js:7

此外,我收到错误:

  

未捕获的ReferenceError:requestAnimationFrame未在file:///android_asset/www/scripts/JSscript.js中定义:4484

我的触摸和点击事件在exxted应用中无效。知道怎么解决这个问题吗?

JS订单:

<script type="text/javascript" src="./scripts/jquery.js"></script>
<script src="http://documentcloud.github.com/underscore/underscore-min.js"></script>
<script src="http://documentcloud.github.com/backbone/backbone-min.js"></script>
<script src='./scripts/JSscript.js'></script>

和JSscript:

var obj;
var profile;    

$(function() {

    // Backbone model Creation
    var ProfileModel = Backbone.Model.extend({

        defaults: {
                tstamp: 'adffdsa',
                map:"",
                tagsCloud:"",
                sentiment: "",
                usersCloud: "",
                timeline: "",
                highlights: "",
                signals: ""
        },

        initialize: function() {

        }

    });

    //Backbone model initialization
    profile = new ProfileModel({
                tstamp: 'adffdsa',
                map:"",
                tagsCloud:"",
                sentiment: "",
                usersCloud: "",
                timeline: "",
                highlights: "",
                signals: ""
    });

    var ProfileList = Backbone.Collection.extend({

                    model: ProfileModel,
                    url: 'data.php'
    });   

    var ProfileView = Backbone.View.extend({

        el: "#profiles",
        template: _.template($('#profileTemplate').html()),
        render: function(eventName) {

        _.each(this.model.models, function(profile){
        var profileTemplate = this.template(profile.toJSON());
        //push data to obj for map script
        obj = profile.toJSON();
        // Add data to DOM element
        $(this.el).html(profileTemplate);
        }, this);

            return this;

        }


    });

        var profiles = new ProfileList([profile]);    
        var profilesView = new ProfileView({model: profiles});

        // Fetching data from server every n seconds
        setInterval(function() {

                profiles.fetch({reset: true});

        }, 4000); // Time in milliseconds

         profiles.bind('reset', function () {

                profilesView.render();

        });     

});

1 个答案:

答案 0 :(得分:0)

编辑:我发现必须在config.xml中定义外部URL。因此,animation.js就像一个魅力。但是,我无法找到为什么backbone.je不起作用。似乎data.php导致了问题。

 var ProfileList = Backbone.Collection.extend({

                    model: ProfileModel,
                    url: 'data.php'
    }); 

我收到了未知铬错误:0。文件data.php位置在localhost上,所以我加入了 config.xml ip adress。但是我仍然收到chromuim错误。任何的想法?