Page 1 of 1

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

Posted: Sun Mar 29, 2015 4:20 pm
by Benjamin Schmid-Lanz

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


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

Posted: Sun Mar 29, 2015 6:28 pm
by M&M

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


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

Posted: Sun Mar 29, 2015 8:26 pm
by Egor Kotov6832188

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


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

Posted: Mon Mar 30, 2015 9:24 am
by Benjamin Schmid-Lanz

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!