Forms
<form>
by clicking a "submit" button. This is a generally anticipated behavior that should be addressed as frequently as feasible.INFO
📙 What you'll learn
Twilight Forms
form
element. Instead, the developer must include a JavaScript onSubmit callback that will send the required HTTP requests. The following is a complete example for adding a form
to collect a comment on a product:
Usage
<form>
element contains the onsubmit
attribute, which is an event
. This event is triggered when the form is submitted. Sequentially, the method salla.comment.add
will be implemented, which is one of the Twilight API JS SDK methods. onSubmit
calls the helper method salla.comment.add
, which in its turn converts all of the form inputs to an object and passes it as arguments to that method. Below is that code that will be run as a result of submitting the previous form:
JS Web Components <salla-button>
<salla-button>
which allows calling functions built by Salla to carry out certain activities.
<salla-button>
is used to submit the form, which causes the helper method salla.comment.add
to be called and implemented. It will be loaded automatically and wait for any response from the server.Response Schema
<salla-button>
component will receive the server Response, which looks like the following schema:
Show Message
message
to the response and a success
flag indicating whether or not the message was successful.Success
Error
Modified at 2025-03-04 12:54:02