header-logo
Getting started with WixBuild your website and business with Wix. Try using our AI tools to create your website, customize templates, or hire professionals to build or enhance your online presence.
Creating a websiteRead how to use the Wix Editor and manage content on your site. Discover how to protect your visitors' privacy and make your site accessible.
Account & billingReview your account settings, manage your subscriptions and plans and understand your invoices.
Using the Wix mobile appsUse our mobile apps to run your business efficiently on the go and set up a dedicated app for your site members to stay in touch.
Connecting a domainFollow our step-by step guides to learn how to purchase, connect or transfer a domain for your site, and find out how to keep your site’s data secure.
Managing your businessGet tools to grow your business and web presence. Find the right tools for your specific needs, set up online payments and keep track of your site's analytics.
Promoting your siteLearn to make your site more visible promoting it on search engines, sending emails and running paid ads. Improve your online presence with practical tips.
Studio, Partners & EnterpriseGet the most out of your Studio or Enterprise account with advanced features that'll help you work more efficiently.
Need more help?Find solutions for site performance and technical issues, learn about issues we’re working to fix or contact us for help.
placeholder-preview-image
Wix LearnImprove your skills with our courses and tutorials.
Wix BlogGet tips for web design, marketing and more.
SEO Learning HubLearn to increase organic site traffic from search engines.
Website developmentBuild a custom site using our full-stack platform.
Hire a ProfessionalGet matched with a specialist to help you reach your goals.
placeholder-preview-image

Wix Blocks: Connecting a Repeater to a Database Collection

Wix Blocks is currently open to a limited number of users.
Blocks allows you to connect a collection to a repeater. Note that Blocks collections are placeholders that allow you to interact with similar structured collections on your site later. To connect a repeater to a collection:
  1. Create or open a Blocks widget through the Widgets and Design menu.
  2. Add a repeater to your widget: go to the Add add panel and click LAYOUT > REPEATERS.
  3. Create a collection in Blocks. 
  4. Go to the code section of the widget and import the wix-data module:
1import wixData from 'wix-data';
5. Query the data in the collection with this syntax (learn more about your app namespace):

@<yourAppNamespace>/<yourCollecitonName>

For example, the following function gets strings from a collection named "Titles" and assign them to the text elements in a repeater:

1$w.onReady(function () {
2 wixData.query('@daphnet2/simple-repeater-app/Titles')
3 .find()
4       .then((results) => {
5           $w('#repeater1').data = results.items
6       })
7       .catch((err) => {
8           console.log(err)
9           throw new Error(err)
10       });
11    $w("#repeater1").onItemReady(($item, itemData, index) => {
12       $item("#text1").text = itemData.title;
13   });
14});
Find the repeater ID
An element's ID is displayed in several places:
  • In the Design tab, when you hover over or select an element.
  • In the Layers layers icon panel, when you select an element.
  • In the Properties & Events panel properties and events icon, when you select an element.

Helpmate

Hello

Need a bit more guidance?
Unlock personalized helpLog in to get the most out of Helpmate.