Skip to content

Instantly share code, notes, and snippets.

@contrerasmarc
Last active August 29, 2015 14:19
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/d238aa8fa1343173414c to your computer and use it in GitHub Desktop.
Save contrerasmarc/d238aa8fa1343173414c to your computer and use it in GitHub Desktop.
A way to discover if a query works or not works
In the view Sites.GeneralDescriptionView :
txtVisits: SC.TextFieldView.design({
layout: Sites.LAYOUT_TXT,
valueBinding: 'Sites.visitsController.content',
// MCM
txtVisitsHasChanged: function() {
var q = Sites.SITES_QUERY;
var s = Sites.store.find(q);
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 sites: ',item,id,sKey,sTatus);
});
}.observes('value')
}),
==============================
In the controller Sites.visitsController :
Sites.visitsController = SC.ArrayController.create(
/** @scope Sites.visitsController.prototype */
{
content: null,
siteIdBinding: 'Sites.siteController.id',
siteIdDidChange: function() {
console.log('siteIdDidChange !!');
var siteId = this.get('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);
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('visits',item,id,sKey,sTatus);
});
}.observes('siteId')
=======================================
In the console:
Shows effectivelly the message 'siteIdDidChange !!', but not information about the records...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment