Is there a way to set event using javascript?
Can't find any method to set event to the object by javascript. The object appears after executing request, so it is not possible to set via graphic redactor.
Catch up wih the Appery.io community on our forum. Here you'll find information on the lastest questions and issues Appery.io developers are discussing.
https://forum.appery.io/
Can't find any method to set event to the object by javascript. The object appears after executing request, so it is not possible to set via graphic redactor.
Can you explain what you exactly mean? If the object is created after executing a request, you can add events to the object - either by jQuery or javascript. If you explain it a bit further perhaps I can help
If user does a request to database, the application gets array of items, which is needed to represent as an list of buttons. Each button has an action by click. So I need a way to set that action. To represent the array as a list I use "mapping", which provides to create new items in the list. How to make that each new button has its own action? What are the names of this javascript methods such as to set event by click on the element?
So it goes like this - You have a list component and on the list item you have a button. Then you have mapped things so that after you invoke the service it adds items dynamically to the list and along with that the buttons. So here's what you could do along with screenshots
What I am doing here is to invoke a service which adds list items / buttons...and in the success event - mapping, I am adding the click event to the element. The JS is shown at the bottom
The javascript itself is couple of lines. All it does in this case is to print the button id to the console, as shown in the picture
code
element.click(function(){
var id = this.id;
console.log("button: " + id);
});
/code
I see, thank you. Is "element" javascript or special papery object?
Nope, it's just referring to the object, in this case it is the button
asa