Page 1 of 1

Manual map of response object to page

Posted: Sun May 04, 2014 6:50 pm
by anon

How would one go about manually mapping the response of a service (data) to elements on the page? How about if there is a list component with arbitrary elements needing to be mapped to a list? Trying to unload a cached page onto identical components on different pages..


Manual map of response object to page

Posted: Sun May 04, 2014 11:15 pm
by Yurii Orishchuk

Hi Anon.

If i understand you correctly you want to create datasource manualy and manualy set for this datasource mapping.

Here is an example of such code:

pre
code

Code: Select all

 dogList = new Apperyio.DataSource(ToDoDB_dogs_list_service, { 
     'onBeforeSend': function(jqXHR) { 

     }, 
     'onComplete': function(jqXHR, textStatus) { 

         Apperyio.refreshScreenFormElements("Screen3"); 
     }, 
     'onSuccess': function(data) {}, 
     'onError': function(jqXHR, textStatus, errorThrown) {}, 
     'responseMapping': [{ 
         'PATH': ['$'], 
         'ID': 'mobilelistitem_5', 
         'SET': [{ 
             'PATH': ['name'], 
             'ID': 'mobilelistitem_5', 
             'ATTR': '@', 
             'SUBSELECTOR': 'h3' 
         }] 
     }], 
     'requestMapping': [{ 
         'PATH': ['X-Appery-Database-Id'], 
         'TYPE': 'STRING', 
         'HEADER': true, 
         'ATTR': '{database_id}' 
     }, { 
         'PATH': ['include'], 
         'TYPE': 'STRING', 
         'ATTR': 'owner' 
     }] 
 }); 

/code
/pre

Regards.