Note that there are some explanatory texts on larger screens.

plurals
  1. PO"TypeError: document is undefined" with jquery-1.10.2.js
    primarykey
    data
    text
    <p>I am creating a BackboneJS project. It works fine in Chrome and Safari, but in Firefox I get errors that stop my app from loading and I cannot work out why.</p> <p>The error is in my jQuery file but it is obviously something in my app that is triggering it because the jQuery library is fine on its own.</p> <p>It is throwing an error on the second line of the jQuery "createSafeFragment" method:</p> <pre><code>function createSafeFragment( document ) { var list = nodeNames.split( "|" ), safeFrag = document.createDocumentFragment(); if ( safeFrag.createElement ) { while ( list.length ) { safeFrag.createElement( list.pop() ); } } return safeFrag; } </code></pre> <p>My main.js that runs the app:</p> <pre><code>Backbone.View.prototype.close = function () { if (this.beforeClose) { this.beforeClose(); } this.remove(); this.unbind(); }; var AppRouter = Backbone.Router.extend({ routes: { '': 'home', 'login' : 'login', 'register' : 'register', 'rosters' : 'rosters', 'workplaces' : 'workplaces', 'groups' : 'groups', 'shifts' : 'shifts', 'logout' : 'logout' }, content : '#content', initialize: function () { window.headerView = new HeaderView(); $('.header').html(window.headerView.render().el); }, home: function () { window.homePage = window.homePage ? window.homePage : new HomePageView(); app.showView( content, window.homePage); window.headerView.select('home'); }, register: function () { window.registerPage = window.registerPage ? window.registerPage : new RegisterPageView(); app.showView( content, window.registerPage); window.headerView.select('register'); }, login: function() { app.showView( content, new LoginPageView()); window.headerView.select('login'); }, rosters: function () { if(Utils.checkLoggedIn()){ app.showView( content, new RosterPageView()); window.headerView.select('rosters'); } }, groups: function () { if(Utils.checkLoggedIn()){ app.showView( content, new GroupsPageView()); window.headerView.select('groups'); } }, shifts: function () { if(Utils.checkLoggedIn()){ app.showView( content, new ShiftsPageView()); window.headerView.select('shifts'); } }, workplaces: function () { if(Utils.checkLoggedIn()){ app.showView( content, new WorkplacesPageView()); window.headerView.select('workplaces'); } }, logout: function () { window.headerView.toggleLogin(false); this.login(); }, showView: function(selector, view) { if (this.currentView) this.currentView.close(); $(selector).html(view.render().el); this.currentView = view; return view; } }); Utils.loadTemplates(['HomePageView', 'HeaderView', 'LoginPageView', 'RegisterPageView', 'RostersPageView', 'GroupsPageView', 'ShiftsPageView', 'UserListView', 'GroupListView', 'ShiftListView', 'SearchedUserListView', 'SearchedGroupListView', 'GroupRosterView', 'RosterListView', 'WorkplacesPageView', 'WorkplaceListView', 'SearchedWorkplaceListView', 'RosterJoinListView', 'GroupUserListView', 'WorkplaceRosterView', 'WorkplaceUserListView', 'RosterShiftView'], function(){ app = new AppRouter(); Backbone.history.start(); }); </code></pre> <p>And my Util.js:</p> <pre><code>Utils = { //template stuff templates: {}, loadTemplates: function(names, callback) { var that = this; var loadTemplate = function(index) { var name = names[index]; $.get('tpl/' + name + '.html', function(data) { that.templates[name] = data; index++; if (index &lt; names.length) { loadTemplate(index); } else { callback(); } }); }; loadTemplate(0); }, get: function(name) { return this.templates[name]; }, //error stuff showAlertMessage: function(message, type){ $('#error').html(message); $('.alert').addClass(type); $('.alert').show(); }, showErrors: function(errors) { _.each(errors, function (error) { var controlGroup = $('.' + error.name); controlGroup.addClass('error'); controlGroup.find('.help-inline').text(error.message); }, this); }, hideErrors: function () { $('.control-group').removeClass('error'); $('.help-inline').text(''); }, //validator stuff validateModel: function(model, attrs){ Utils.hideErrors(); var valError = model.validate(attrs); if(valError){ Utils.showErrors(valError); return false; } return true; }, //loading stuff toggleLoading: function(toggle){ $('#loading').css('visibility', toggle ? 'visible' : 'hidden'); }, //login stuff login: function(auth){ window.headerView.toggleLogin(true); Backbone.history.navigate("", true); }, checkLoggedIn: function(){ if(!window.userId){ window.headerView.toggleLogin(false); Backbone.history.navigate("login", true); return false; } return true; }, //util methods formatDate: function(date){ var formattedDate = ''; formattedDate += date.getFullYear() + '-'; formattedDate += date.getMonth()+1 + '-'; formattedDate += date.getDate(); return formattedDate; }, formatDateForDisplay: function(date){ var formattedDate = ''; formattedDate += date.getDate() + '/'; formattedDate += date.getMonth()+1 + '/'; formattedDate += date.getFullYear() + ' - '; formattedDate += ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'][date.getDay()]; return formattedDate; }, formatDateForGroup: function(date){ var formattedDate = ''; formattedDate += date.getDate() + '/'; formattedDate += date.getMonth()+1; return formattedDate; }, showPopup: function(id, buttons, title, content){ var popup = $(id); popup.dialog({ modal: true, title: title, buttons: buttons }); popup.find('#popupContent').html(content); } }; </code></pre> <p>Someone please help me as this is driving me crazy! Firefox only...</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload