1

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.

K_C
  • 393
  • 1
  • 7
  • 20
  • Hm, Parse.View doesn't exist in the Parse JavaScript SDK so it is no wonder that this doesn't work. Or am I missing something here? – Björn Kaiser Nov 03 '15 at 20:20
  • It looks like it is included based on their guide: https://parse.com/docs/js/guide But it does call out that Parse.View requires "...that you provide jQuery or a jQuery compatible $ method." I believe I've done that correctly (maybe). But this is driving me nuts. – K_C Nov 03 '15 at 20:41
  • Update: It looks like you're right, @BjörnKaiser, Parse.View isn't in the latest JS SDK. Looks like it might've been dropped from 1.5 to 1.6. Using the sample ToDo app, I updated the SDK to latest and the app no longer works, generating the same "Cannot read property 'extend' of undefined" – K_C Nov 04 '15 at 13:56
  • Yeah, I think it used to be based on Backbone but isn't anymore so the docs seem outdated. There is already an open issue on GitHub that seems to be reporting this/something similar https://github.com/ParsePlatform/Docs/issues/247 – Björn Kaiser Nov 04 '15 at 14:13
  • Looks like you guys already have the answer on this but I thought I would include this link to another SO question which summarizes: http://stackoverflow.com/questions/32722575/how-do-i-implement-the-backbone-model-in-latest-parse-js-sdk-1-6-2 – Daniel Bank Nov 07 '15 at 16:31

0 Answers0