Hi all,
Can anyone see a mistake in this code? I am not able to click on the checkboxes in my checkboxGroup - m1SportsTags. I made sure to enable them and they are at the top level.
page name = profile update
database= SportsCategories
text input = formM1SportsInput
button = m1SportAdd
checkboxgroup = m1SportsTags
checkbox selections go into the 1425ClubMembers database
import wixData from 'wix-data';
import { currentMember } from 'wix-members';
//load sportCategories into m1SportsTags checkboxes
//insert into the page $w.on Ready()
$w.onReady(() => {wixData.query('SportsCategories')
.ascending('title')
.find()
.then(res => {
let options = [];
options.push(...res.items.map(title => {
return { "value": title.title, "label": title.title };
}));
$w('#m1SportsTags').options = options;
})
.catch((err) => {
let errorMsg = err;
});
});
//insert this code into the page code, outside of the page $w.on Ready()
//adds a new category into checkboxgroup from the SportsCategories database
export function m1SportAdd_click(event) {
wixData.insert('SportsCategories', {
'title': $w('#formM1SportsInput').value
})
$w("#formM1SportsInput").value = null;
//setup the checkboxes again
$w.onReady(() => {
wixData.query('SportsCategories')
.ascending('title')
.find()
.then(res => {
let options = [];
options.push(...res.items.map(title => {
return { "value": title.title, "label": title.title };
}));
$w('#m1SportsTags').options = options;
})
});
}
//Connect the Checkboxes to the 1425ClubMembers dataset
//on html page select the checkboxgroup $w('#m1SportsTags') and link it to 1425ClubMembers //dataset, m1Sports field(tags).
@Sylvia McConnell When you can't click on an option group to select an option when it's tied to a dataset, it means there is not a current item. It's not entirely clear from your code what you are trying to do, but maybe it's just a matter of using the dataset add function to get a blank record in there. Or maybe you just need to get the dataset on an already existing record.
bump not sure what I am doing here I'm just trying to get an answer to my question. Can any body help! See below