Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
2nd chance...
sc_require('models/visit_model');
Sites.visitsController = SC.ArrayController.create(
/** @scope Sites.visitsController.prototype */
{
content: null,
siteIdBinding: 'Sites.siteController.id',
siteIdDidChange: function() {
var siteId = this.get('siteId');
console.log('siteIdDidChange !!', siteId);
var newQ = SC.Query.local(Sites.VisitModel, {
conditions: "site_id = {qSite} AND type = 'visit' ",
// conditions: "type = 'visit' ",
parameters: {
qSite: siteId
}
});
var c = Sites.visitsController.get('content');
if (c) c.destroy();
// var s = Sites.store.find(newQ);
var s = Sites.store.find(Sites.VisitModel);
console.log('The visits: ',s, s.get('lenght'));
Sites.visitsController.set('content', s);
var id, sKey, sTatus;
s.forEach(function(item, index, self) {
id = item.get('id');
sKey = item.get('storeKey');
sTatus = item.get('status');
console.log('The visits: ',siteId, item,id,sKey,sTatus);
});
}.observes('siteId')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment