Inside the $ .getJSON success function, I first fire the element's click event:
$('#' + data[0].ID).trigger('click');
The click-triggered event has its own $ .getJSON method for loading a bunch of data into a div. The next line after the event is fired:
$.each(data[0].ListEntries, function (key, val) {
At first, $ .each did not seem to do anything, but I added a warning immediately after the event triggered. After responding to the warning, the code in $ .each shows what it should.
I assume that $ .each works before the click event finishes loading the data.
setTimeout pauses long enough for the click event to load data, but I would prefer not to set an arbitrary time:
setTimeout(function() { $.each(data[0].ListEntries, function (key, val) {
I also tried $ .when and $, but to no avail (although adding a warning to $ .each inside $. Then creates a delay for $ .each to work):
$.when($('#' + data[0].ID).trigger('click')).then(function () { $.each(data[0].ListEntries, function (key, val) {
jquery
Chris m
source share