Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Dynamically defning Mojits.
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.