Created
July 26, 2013 09:37
-
-
Save akshar100/6087592 to your computer and use it in GitHub Desktop.
Dynamically defning Mojits.
This file contains hidden or 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
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