Skip to content

Instantly share code, notes, and snippets.

@otmezger

otmezger/app.js Secret

Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save otmezger/b42470ff2c9d48184401 to your computer and use it in GitHub Desktop.
Save otmezger/b42470ff2c9d48184401 to your computer and use it in GitHub Desktop.
How to use Parse.query in a collection (Backbone like) on Stackoverflow
Parse.initialize("xxx", "xxx");
var AppRouter = Parse.Router.extend({
routes: {
"class-list": "listClasses"
},
initialize: function () {
var self = this;
this.loginView = new LoginView();
// ----------------------------------------------------CLASS
// |-----> Collection
var ClassModel = Parse.Object.extend("Classes");
this.classModel = new ClassModel();
// |-----> Query
var ClassQuery = new Parse.Query(ClassModel);
// |-----> Collection
var ClassCollection = Parse.Collection.extend({
model: ClassModel,
query: ClassQuery
});
this.classCollection = new ClassCollection();
// |-----> View
var ListClassView = Parse.View.extend({
initialize: function () {
//this.listenTo(this.collection, "reset", this.render);
},
render: function () {
this.$el.html(Handlebars.templates.class_list(this.collection));
return this;
}
});
this.listClassView = new ListClassView({
collection: self.classCollection
});
this.classCollection.fetch();
},
});
var app = new AppRouter();
Parse.history.start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment