Created
April 23, 2015 15:20
-
-
Save contrerasmarc/df626b5245c2a98b119f to your computer and use it in GitHub Desktop.
2nd chance...
This file contains 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
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