top of page
Filter events by category

Filter events by category

Create a filter to filter events by assigned categories.

Intermediate.png

Intermediate

6K

Published:

January 16, 2024

Girl Enjoying her Drink

by

Anchor 1
Hire a Developer

Example Description

Custom Elements allow you to embed a Web Component in a page. In this example, we demonstrate sending information from the page to the Custom Element and from the Custom Element to the page.


Note that custom elements only work fully on premium sites with a connected domain.

Example Code

.

.

This code solution can be complicated.

How We Built It

Page Elements


We split the HOME page into 2 sections.


The top section contains regular Wix elements. It has 2 text elements: one is used as a label and the other is used to display information passed to the page from the Custom Element. This section also contains a button used to send a message to the Custom Element.


The bottom section contains a Custom Element. Inside the element we use CSS, and JavaScript to create 2 text elements and a button. One text element is used as a label and the other is used to display information passed to the Custom Element from the page. The button used is used to send a message to the page.


Page Code


We added 2 event handlers to the HOME page.


The first event handler runs when the button to send messages from the page to the Custom Element is clicked. It uses the Wix `setAttribute()` function to send the message.


The second event handler runs when a message is received from the Custom Element. It populates the received message into the text element with the ID `message`.


Custom Element Code


The Custom Element's code can be found in the Public section of the Velo Sidebar.


The code begins with some functions that create HTML elements that will be added to the Custom Element.


Next there is a function that creates the styles for the HTML elements.


Finally, there is a class that defines the Custom Element itself. Inside the class, there is code for adding HTML elements to the Custom Element, including code for sending a message to the page when the button is clicked. There is also code for handling messages sent from the page.

APIs We Used

Non-code example.

Related Articles

Article Link

Hire a Developer

Velo solutions are powerful tools, but building them on your own can be challenging. Let an experienced Velo development shop build it for you, so you can keep working on your site or business.

Related Examples

Did this help?

Yes

|

No

Thanks for your feedback!

Custom Event Ticket Purchase Flow

Custom Event Ticket Purchase Flow

Create a custom ticket purchase flow without using the Wix Events widget

Intermediate.png

Intermediate

Custom Event Ticket Picker on Events Frontend

Custom Event Ticket Picker on Events Frontend

Create a custom ticket picker for your events.

Intermediate.png

Intermediate

Anchor 2

This website was designed with Velo by Wix

bottom of page

We use cookies and similar technologies. You can opt-out by clicking 'Do Not Sell or Share My Personal Information' at the bottom of the page.