Render instructions with asynchronous callback

50 views
Skip to first unread message

Juha Mustonen

unread,
Jul 10, 2012, 9:03:44 AM7/10/12
to transpa...@googlegroups.com
Hi,

Is it possible to use asynchronous function when providing rendering instructions to Transparency?
As an example:

var data = [{id: 123}, {id: 422}];

var renderInstructions = {'user': {html: function(){
  var formattedData = 'placeholder';
  // Fetch actual data from backend
  $.getJSON('backend/user', {id: this.id} function(completeData) {
    formattedData = completeData.firstName + ' ' + completeData.lastName;
  }
  return formattedData;
};


// <ul><li class="user"></li></ul>
$('ul').render(data, renderInstructions);

Or what is the suggested approach in these cases?

Br,
Juha

Mikko Ohtamaa

unread,
Jul 10, 2012, 9:16:03 AM7/10/12
to transpa...@googlegroups.com

Is it possible to use asynchronous function when providing rendering instructions to Transparency?
As an example:


Or what is the suggested approach in these cases?

Call render() from $.getJSON() success callback?
 

Br,
Juha

Mikko Ohtamaa

unread,
Jul 10, 2012, 9:16:46 AM7/10/12
to transpa...@googlegroups.com

Juha Mustonen

unread,
Jul 10, 2012, 9:21:45 AM7/10/12
to transpa...@googlegroups.com
Excellent. Thanks for the prompt answer.

On Tue, Jul 10, 2012 at 4:16 PM, Mikko Ohtamaa <mi...@redinnovation.com> wrote:
> An example can be found in Wiki:
> https://github.com/leonidas/transparency/wiki/Populating-a-table-using-jQuery-and-AJAX
>>>
>>> Is it possible to use asynchronous function when providing rendering
>>> instructions to Transparency?
>>> As an example:
>>>
>>>
>>> Or what is the suggested approach in these cases?
>>
>> Call render() from $.getJSON() success callback?
>>

--
Juha
Reply all
Reply to author
Forward
0 new messages