Skip to content

Instantly share code, notes, and snippets.

@bsingr
Created March 15, 2010 18:20
Show Gist options
  • Select an option

  • Save bsingr/333129 to your computer and use it in GitHub Desktop.

Select an option

Save bsingr/333129 to your computer and use it in GitHub Desktop.
[...]
wrapped_callback = function(response) {
var new_content = response,
all_content = "";
$.each(data_array, function(i, idata) {
// extend the data object with the context
//---------------------------------------
// dpree:
// the following line eats some of my data, e.g.: {"items": myItems}
//---------------------------------------
$.extend(idata, context);
//---------------------------------------
// dpree:
// i don't know for what the sammy-context is needed, but maybe we could do instead sth. like:
// $.extend(idata, {"___context___": context});
//---------------------------------------
if ($.isFunction(engine)) {
new_content = engine.apply(context, [response, idata]);
}
// collect the content
all_content += new_content;
// if callback exists call it for each iteration
if (callback) {
// return the result of the callback
// (you can bail the loop by returning false)
return callback.apply(context, [new_content, i]);
}
});
if (!callback) { context.swap(all_content); }
context.trigger('changed');
};
[...]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment