I've been working with Parse for a couple years, but primarily iOS. Working on a simple web app companion and hitting a wall on what is surely a simple issue. Trying to create a view after a query, but getting an error:
Uncaught TypeError: Cannot read property 'extend' of undefined
Full code is below. I'm using Handlebars for the template. Parse storing and accessing User.current()
and executing the query as expected.
$(function() {
"use strict";
Parse.$ = jQuery;
// Initialize Parse
Parse.initialize("XXXXXXXX", "XXXXXXXX");
// Get the Business Details
var BusinessDetail = Parse.Object.extend("BusinessDetails");
var query = new Parse.Query(BusinessDetail);
query.equalTo("businessAdmin", Parse.User.current());
query.find({
success: function(businessDetails) {
console.log(businessDetails);
var businessDetailsView = new BusinessDetailsView({ model: businessDetails });
businessDetailsView.render();
$('.wrapper').html(businessDetailsView.el);
},
error: function(businessDetails, error) {
console.log(error);
}
});
var BusinessDetailsView = Parse.View.extend({
initialize: function() {
console.log( "view initialized");
},
template: Handlebars.compile($('#businessDetails-tpl').html()),
render: function(){
var attributes = { businessDetail: this.model.toJSON() };
this.$el.html(this.template(attributes));
}
});
});
I've messed around with the loading of jQuery, underscore, handlebars JS as well as my site scripts, in case it was out of order. Can't seem to crack this very basic issue. Any thoughts or tips pointing me in a direction would be appreciated.