Page 1 of 1

Is there a way to dynamically create pages using a REST response

Posted: Thu Feb 13, 2014 11:36 am
by danpickard

When using a service I get x amount of responses from my own API.

Ideally I'd like to have each page link off to a dynamic page that changes according to what item has been selected, taking the input from the click as the input parameter, querying other data from my DB through my API

Any guidance would be appreciated


Is there a way to dynamically create pages using a REST response

Posted: Thu Feb 13, 2014 12:55 pm
by Maryna Brodina

Hello! Could you clarify why do you need dynamically create pages? Pass necessary data through localStorage on target page and using these parameters load on page you need necessary component.


Is there a way to dynamically create pages using a REST response

Posted: Thu Feb 13, 2014 3:03 pm
by danpickard

On my page I've got a collapsible tab which then has a list in it. When the page opens it loads a list of items (in this case 2 football league names) by connecting to my external API to the list, generating 2 list items called "premier league" and "La Liga".

Image

Ideally I'd like to have one 'Leagues' page, which is populated with data from my API, but is dependent on which "League Name" that I click. So if I click 'Premier League' the leagues page (which has a list on it) is updated with the 20 team names that the premier league is made up of like this:

Image


Is there a way to dynamically create pages using a REST response

Posted: Thu Feb 13, 2014 4:43 pm
by Kateryna Grynko

Hi Dan,

Depending on the selected league, you can send specific requests to your API and accordingly modify a page header.


Is there a way to dynamically create pages using a REST response

Posted: Thu Feb 13, 2014 8:29 pm
by danpickard

any clue as to how I would do this? Would I need to create some JavaScript that passes the value of the league name to the API request?


Is there a way to dynamically create pages using a REST response

Posted: Thu Feb 13, 2014 9:07 pm
by Kateryna Grynko

Dan,

If your API works this way (requires a league name and returns values), then yes.


Is there a way to dynamically create pages using a REST response

Posted: Thu Feb 13, 2014 9:42 pm
by danpickard

So far I have this but I'm looking to enter a value for leagueName here as well, then execute this service on another page. Any ideas?

code Appery("footballLeaguesListItem").onClick(TeamsRESTService.execute({"data": {"paramName": leagueName}}));
/code


Is there a way to dynamically create pages using a REST response

Posted: Fri Feb 14, 2014 4:02 pm
by Kateryna Grynko

Hi Dan,

Why don't you use standard click event handlers?
http://docs.appery.io/documentation/w...
And map request parameters: http://docs.appery.io/documentation/r... ?