public
Created

Dynamically defning Mojits.

  • Download Gist
mojits.1.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
var adapter = {
flush : function(data, meta) {
},
done : function(data1, meta) {
 
counter++;
 
queue.push(data1);
Y.mojito.util.metaMerge(parentMeta, meta);
//For Binders to work!
if (counter === data.length) {
 
//now get comments for each post
ac.composite.done({
sections : queue
}, parentMeta);
 
}
 
},
error : function(err) {
Y.log(err);
}
};
adapter.req = ac._adapter.req;
for (var i in data) {
if (data[i].images) {
data[i].images = JSON.parse(data[i].images);
}
(function(dt) {
ac.models.get('contentMojitModelFoo').getComments(dt.id, function(err, comments) {
 
if (!err) {
dt['comments'] = comments;
}
if (err) {
dt['comments'] = [];
}
ac._dispatch({
"instance" : {
"type" : "postMojit",
"config" : {
"deploy" : true,
"children":{
"comment":{
"type":"commentMojit"
}
}
}
},
"action" : "index",
"context" : ac.context,
"params" : {
body : {
data : dt,
user_id:ac.session.get("user_id") || 23
}
}
}, adapter);
});
})(data[i]);
 
}
 
});
},
create_possessions : function(ac) {
 
Y.log("Running Create Possesions")
ac.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.