I have a dataset named ‘To Do’. On click, I want to save the current item title and the input in the text field to the dataset. But unable to achieve that. Requesting to guide me.
import wixData from 'wix-data';
var projectName
$w("#dynamicDataset").onReady(() => {
let item = $w("#dynamicDataset").getCurrentItem();
projectName = item.title;
console.log(item)
console.log(projectName)
})
let toInsert = {
"project": projectName,
"toDo": $w("#toDoBox").value
};
export function toDoBtn_click(event) {
wixData.insert("ToDo", toInsert)
.then( (results) => {
let item = results;
console.log(item)
} )
.catch( (err) => {
let errorMsg = err;
} );
}