danpickard
Posts: 0
Joined: Wed Feb 12, 2014 2:37 pm

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

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

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

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

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.

danpickard
Posts: 0
Joined: Wed Feb 12, 2014 2:37 pm

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

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

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

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

Hi Dan,

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

danpickard
Posts: 0
Joined: Wed Feb 12, 2014 2:37 pm

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

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?

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

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

Dan,

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

danpickard
Posts: 0
Joined: Wed Feb 12, 2014 2:37 pm

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

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

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

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

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... ?

Return to “Issues”