This is the Wix Code version of the TodoMVC project . Using input components in a Repeater, the Data binding and Data API implementations (on separate pages) are functionally the same and demonstrate different techniques for the developer.
Await and Async is used to wait for an action or function to be completed until it moves to the next action / function. here is good page on the matter: Async/await
Its so great example. i struggled with save and refresh problem for weeks. It didnt want to refresh repeaters after save. Thanks to await async it works now. Sooooooooooooooooooooooooo Greaaaaaaaaaaat. Those editor exapmles are powerfull becasue i can see everything connected (code, layout, collection) . For “code changer” not developer like me its time saving. Thanks a lot for for such examples
Could You explain what exacly means _ in this code. I understand you find id of item’s repeater but where i can find more about this “_” how to use it?
data.find(_ => _._id === itemId);
export async function checkbox1_change(event) { let $item = $w.at(event.context); let itemId = event.context.itemId; let newValue = $item(‘#checkbox1’).checked; let item = $w(‘#repeater1’).data.find(_ => _._id === itemId);
item.completed = newValue; await saveItem(item);
Typically, the underscore character _ is used as a don’t care variable. That is, it’s just a way to say “here’s where a variable goes, but we’re not going to use it”.
However …
In the code you referred to, _ is just being used as a variable. The underscore _ and the dollar sign $ can both be used as variables. It’s just a matter of style.
If I already have code written with HTML, CSS and JavaScript…is there any other code I could use to populate the to do list on the page without connecting to the database? I’m just not understanding how to conncect a separate form I’ve created to a database on Wix.
The only way to use HTML/CSS/Javascript code on a Wix site, is to use an HtmlComponent. If you want to connect to a database collection, you will need to send messages from the code in the HtmlComponent to the page. Code on the page can then get the data from the messages and save it in a collection.
Using HTML/CSS/Javascript code on a Wix site is not recommended. Wix supplies all of the tools that you need to create your own interactive forms, including: screen components, database collections, and Corvid (which allows you to add functionallity).
The Live example only shows the items I have entered (no items that have been added by any other users), but when I publish the Example template the items I enter are shown when I open the published page in another browser and on another device. How did you get the Live example to do this? I’m setting up a calculator and would like each user to only see the data they have entered.
is there a way to add a delete button for a specific to do list item? Like if the user wants to delete a specific item can there be an “X” when you hover over a line and the item be deleted from list and database?