Hey there,
I ran into a problem today, that I cannot figure out how to fix.
Its on my ‘click’ event, when i try to load my data
'click .gridButton': function(event) {
Result = Template.instance().gqlQuery({ query: MY_QUERY, variables: {id:event.target.id}}).get();
},
This is my click-event. I am using the swydo:Blaze-Apollo Framework, so I can call queries inside my templates.
But it does not work on the first click.
On my first click, the query is always empty. Following clicks do work however.
I thought it maybe had sth to do with the data not being loaded at that point, so I created a function which calls the .get() every second to see if it is not empty anymore - but the problem persist. Its empty until I click a second time.
Maybe it has something to do with caching, I just dont know how to test that. Maybe its my function, which calls the get every second?
This is my function, which should wait for the data to be loaded.
WaitForDataToBeLoaded = function(data,time, func) {
if(data!= undefined)
{
func(data);
}
else
{
setTimeout(function() {
waitForDataToBeLoaded(data, time, func);
}, time);
}
}
I really hope someone can help me with that.
Thanks in Advance!