Benjamin Schmid-Lanz
Posts: 0
Joined: Sun Mar 29, 2015 4:20 pm

How do i get the id of the clicked element from the service?

I am doing an Wordpress-App. For Communication i get JSON-API-Responses from my Wordpress site, that i use to create a list of my articles.

Now i want to load the article when clicking on it, but for that i need to get the id of the clicked article from the Service Reponse.

Then i pass the id into storage and open my "post-page". This Page invokes a JSON-Request to get the information from my wordpress site.

But how do i get the id of the clicked element from the service?
Image Image

M&M
Posts: 0
Joined: Tue Nov 11, 2014 6:59 am

How do i get the id of the clicked element from the service?

You can place a hidden label and map the ID to that label. Then you can add this to click event handler

code
var clicked_row = jQuery(this).closest("tr");
var clickedID= row.find('[name="hiddenLabel"]').text();
/code

Egor Kotov6832188
Posts: 0
Joined: Wed Nov 19, 2014 5:15 pm

How do i get the id of the clicked element from the service?

Hello Benjamin,

You don't have an id in your HTML page, cause you haven't maooed it.

1) Add a label
2) make it invisible
3) on click event add set local storage
4) select any temp variable and bind it to label
5) in Data tab for this service in before send request map temp var to your request parameter

Benjamin Schmid-Lanz
Posts: 0
Joined: Sun Mar 29, 2015 4:20 pm

How do i get the id of the clicked element from the service?

Ok, thx.

Just one Problem left. I have to send the id to my wordpress-Installation like that:

www.example.com/?json=get_post&post_i...

So i try to set a Request-parameter. But i don ́t know how :P

That ́s the plugin I am using: https://wordpress.org/plugins/json-ap...

Thanks a lot Image

EDIT: It ́s working if i pass HTTP://www.example.com/?json=get_post&post_i... directly in the Request url. but not if i put it as an request-query-string

EDIT: Got it working by Importing the string to request-query-strings! thx!

Return to “Issues”