Skip to content
This repository has been archived by the owner on Aug 25, 2018. It is now read-only.

ReferenceError: Firebase is not defined line 153 in backbonefire.js #160

Open
Bart-Holland opened this issue Mar 9, 2017 · 3 comments
Open

Comments

@Bart-Holland
Copy link

Hi I am trying to run this model:

var APP = APP || {};

APP.FBLocationsModel = Backbone.Firebase.Model.extend({

    urlRoot: APP.fireBase.config.databaseURL + 'users/',
    autoSync: true,

    initialize: function () {

        this.listenToOnce(this, 'FBInit', this.setUrl);
        this.connectWithFirebase();

    },

    setUrl: function () {

        this.url = this.urlRoot + FB.uid + "/locations/";

    },

    connectWithFirebase: function () {

        var that = this;

        //check if firebase config is there
        if (APP.fireBase.config) {
            FB.config = APP.fireBase.config;
        } else {
            throw("Need firebase config object");
        }

        //initialize -> auth -> login
        FB.init(function () {
            that.trigger('FBInit')
        });

    }
});

and in the code I do this:

APP.fbLocationsModel = new APP.FBLocationsModel();
APP.fbLocationsModel.fetch();

After doing so I get this error in my console:
ReferenceError: Firebase is not defined line 153 in backbonefire.js

Firebase itself is loaded (version 3.6.10)
looking in the code ofr backbonefire.js I see this code:

Backbone.Firebase._determineRef = function(objOrString) {
        switch (typeof(objOrString)) {
            case 'string':
                return new Firebase(objOrString);
            case 'object':
                return objOrString;
            default:
                Backbone.Firebase._throwError('Invalid type passed to url property');
        }
    };

In the case 'string' I is where it says: 'Firebase is not defined' but can't figure out why.
I do use require, maybe that is an issue here?

@FlxAlbroscheit
Copy link

Hi Bart, sorry for my late response. Next time, please mark clearly which exact line of your posted code caused the error as we can't see any lines here ;) Nevertheless, please note that only Collections have to extend from 'Firebase', not models (they stay Backbone.Model.extend({...})). Furthermore your model makes less sense, in order to achieve such functionality in harmony with Backbone's architecture, think about putting the code into the app's router or a controller-like-init-class.

@Bart-Holland
Copy link
Author

Bart-Holland commented Apr 11, 2017 via email

@wuservices
Copy link

wuservices commented Oct 2, 2017

This seems like #161 since new Firebase(objOrString); doesn't work with Firebase 3.x or 4.x.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants