-
-
Save otmezger/b42470ff2c9d48184401 to your computer and use it in GitHub Desktop.
How to use Parse.query in a collection (Backbone like) on Stackoverflow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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