Skip to content

Instantly share code, notes, and snippets.

@contrerasmarc
Created April 23, 2015 15:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save contrerasmarc/df626b5245c2a98b119f to your computer and use it in GitHub Desktop.
Save contrerasmarc/df626b5245c2a98b119f to your computer and use it in GitHub Desktop.
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