Anil Sagar
Posts: 0
Joined: Fri Jul 04, 2014 1:13 pm

How to simulate buying a product?

I am trying to create a mock app for buying a product. Pls see the snapshot below. There are 2 products shown. Each is stored in an appery collection as an array (in a column) with various attributes like product description, price, image etc.

Page uses a grid and shows a buy button for each product.

Now my problem is how to associate a particular button to a particular product. That is - if I press top button then I should be able to buy the top product.

So how to make sure that pressing the first button initiates actions for the first product in the array? Pressing 2nd button should lead to action on the second product in the array? Image

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

How to simulate buying a product?

Hello Anil,

Please clarify do you get all these descriptions of products and buttons via mapping?
In General steps are:
If you add js code on click on the button, in this code this variable this will indicate to the button the user clicked. In the js code, you will be able to find in what container is this button. In this container you will be able to find hidden label with product id
This will help http://api.jquery.com/category/traver...

Anil Sagar
Posts: 0
Joined: Fri Jul 04, 2014 1:13 pm

How to simulate buying a product?

Hi Evgene, yes I am getting product descriptions of products and buttons via mapping. Does it change your code suggestion above?

Also, I am not clear on your statement - "In this container you will be able to find hidden label with product id"

Button is sitting inside a grid. But what do you mean by "hidden label with product id". Where in the grid properties will I find it?

Also, the link that u have shared is for a tree. I am not using tree but an array.

Where can I find more info on using "this". Are there any tutorials or any other queries in this forum? I tried searching but could not find.

Anil Sagar
Posts: 0
Joined: Fri Jul 04, 2014 1:13 pm

How to simulate buying a product?

Appreciate some help on this pls

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

How to simulate buying a product?

Hello Anil,

For each product you should map its id too. And if you don't want to mess the design, you may do this in a hidden label. Your task can be solved by the model of master-detail page. Here is the link to the documentation:
http://devcenter.appery.io/documentat...

Anil Sagar
Posts: 0
Joined: Fri Jul 04, 2014 1:13 pm

How to simulate buying a product?

Thanks Evgene. After a lot of deliberation and some help from the following forum query, I was able to crack it. Although your link above is also good help for anybody who wants to solve this.

https://getsatisfaction.com/apperyio/...

Using this command was quite helpful from the query above:
var id = $(this).parent().find("[name=lblId]").text();

This also clarifies the concept of "parent" component. I can now relate to your earlier answer much better...:-)

Return to “Issues”