Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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