javascript - How to access returned objects from query so that images can be displayed? -
parse.com , javascript.
the code below returning correct results, per screen shots, but..
how can return , access each of objects has been captured query? want use "pic" column held within _user class. @ moment images returning undefined.
var currentuser = parse.user.current(); var friendrequest = parse.object.extend("friendrequest"); var query = new parse.query(friendrequest); query.equalto("fromuser", currentuser); query.equalto("status", "request sent"); //query.exists("pic"); query.find({ success: function(results) { // if query successful, store each image url in array of image url's imageurls = []; (var = 0; < results.length; i++) { var object = results[i]; imageurls.push(object.get('pic')); } // if imageurls array has items in it, set src of img element first url in array for(var j = 0; j < imageurls.length; j++){ $('#imgs').append("<img src='" + imageurls[j] + "'/>"); } }, error: function(error) { // if query unsuccessful, report errors alert("error: " + error.code + " " + error.message); } }); // show signup or login page </script>
if images stored in relation array "pic" element in "friendrequest" have additional relation query retrieve array ....
this.collection = new userlist(); this.model = this.options.model; // check whether user or role shoul b user var relation = this.model.relation("users"); this.collection.query = relation.query(); var role = this.model.id; var rolename = this.model.get("name"); this.collection.fetch();
above module works parse._roles has "users" field - array of type relation
to work relation pointers in "user" , 'relation' query required. after fetch, in collection, have array of pointers want images.
Comments
Post a Comment