这个小提琴或多或少地显示了我正在尝试做的事情。
我正在从 Parse.com 数据库中查询一些结果。结果在成功回调中返回。
谁能告诉我在mainView()
函数中与他们合作的最佳方式?我想将所有查询与其显示方式的逻辑分开。我已经尝试了很多不同的方法,但无法让它发挥作用。
这个小提琴或多或少地显示了我正在尝试做的事情。
我正在从 Parse.com 数据库中查询一些结果。结果在成功回调中返回。
谁能告诉我在mainView()
函数中与他们合作的最佳方式?我想将所有查询与其显示方式的逻辑分开。我已经尝试了很多不同的方法,但无法让它发挥作用。
只需this
在回调外部存储一个引用。
var userInterface = {
newQuery: function() {
var that=this; //store a reference to "this"
Query = Parse.Object.extend("Test");
query = new Parse.Query(Query);
query.descending("createdAt");
query.equalTo("column1", "a");
query.find({
success:function(results){
that.mainView(results); //that points to the userInterface object
},
error:function(error){
}
});
},
mainView: function(res){
console.log(res);
},
init: function() {
this.newQuery();
}
};
userInterface.init();