Hi,
Right now I'm learning .js but I got stuck on this.
In regular code document.write shows the output on the page but on wix we have to use .show() so I have two very basic questions.
1.how can I show this code in the text of my repeater?
$w.onReady(function () {
getData()
.then((response) => {
let subCount = response.items[0].statistics.subscriberCount;
console.log(subCount);
$w("#subCount").show();
As you can see my code it successfully running on the console but it's not showing the output on the repeater text I connected.
2. How can I get the database field item in the backend?
As you can see I'm taking const but when I want to take database field item like this:
//const id = "****************";
var id = $w('title');
it's not working & not giving any error too.
If I'll find my old work from this website https://ipayzz.com/credit-card/ , I'll tell you how to do that, but for now I can only recommend you to look for answers on youtube. I found solution there.
What whisky said, but also:
document.write and show() are completely different things.
.show(); is the Corvid equivalent to .style.visibility = 'visible';
Anything after double slashes is just a comment intended for humans - it is not read by the computer. //const id... does nothing
Use let instead of var. You can find plenty of resources on what the difference is if you want, but it's just better practice.
$w is a selector, thus is used exclusively for front-end. Backend = server functions, and the server only delivers/receives data, it cannot read page elements.
Have you read the Wix API Reference for Repeater?
https://www.wix.com/corvid/reference/$w.Repeater.html
How do I populate a repeater with new data?
The most common way to populate a repeater is as follows:
Set the repeater's data using the data property. This triggers the second step for all items in the data array with a new ID.
Populate the repeater with data from the new items using the onItemReady() function.
If you just want to call data from a dataset, then just use getCurrentItem from Wix Dataset.
https://www.wix.com/corvid/reference/wix-dataset.Dataset.html#getCurrentItem