Hello !
I have a problem, and I appeal to you because I can not find any solution.
I have a repeater which contains a block with a title and buttons. I wish I could change the title of the block in question. To do this, you must click on the modify button of the block in question. A block is displayed with a input. When I change the input and click on the save button, the block in question should update the title! Except this is not the case, if I modify any title of any block, this one modifies only on the first block of the repeater!
I do not understand, here is a video that films the problem I am having:
Here is my code below :
$w("#repeater1").onItemReady( ($w, itemData, index) => {
$w("#buttonmodify").onClick((event, $w) => {
$w('#boxtitle').show();
});
$w("#savetitle").onClick((event, $w) => {
let $item = $w.at(event.context);
let newValue = $item('#inputtitLe').value;
$item('#dataset1').setFieldValue('shortTextField', newValue);
$w('#dataset1').save()
.then( () => {
$w('#boxtitle').hide();
})
});
});
Please help me i don't understand why it does this :(
Hi Lukas !
The code would be more like ->
$w.onReady(function () { $w("#repeater1").onItemReady(($item, itemData, index) => { $item("#buttonmodify").onClick((event) => { var currentItem = itemData._id; wixData.query("responsiveContactForm03") .eq("_id", currentItem) .find() .then((results) => { let item = results.items[0]; $item('#boxtitle').show(); $item('#inputtitle').value = $item('#text42').text; $item("#savetitle").onClick((event1) => { let value = $w('#inputtitle').value; item.good = value; wixData.update('responsiveContactForm03', item) .then((resuls1) => { console.log("submitted"); $w('#dataset1').refresh(); }) .catch((error) => { let errorMsg = error.message; let code = error.code; console.log(error.message); }); }); }); }); }); });
All the best !!
Try what is posted here ->
https://www.wix.com/corvid/forum/main/comment/5f37fdb85b221800170dc9a9
$w.onReady(function () { var item; $w("#repeater1").onItemReady( ($item, itemData, index) => { $item("#buttonmodify").onClick((event) => { var currentItem = $w('#dataset1').getCurrentItem()._id; wixData.query("Database") //database name .eq("_id", currentItem) .find() .then( (results) => { item = results.items; $item('#boxtitle').show(); $item('#inputtitle').value = $item('#text42').text; }); }); $item("#savetitle").onClick((event) => { var newValue = $item('#inputtitle').value; item.shortTextField = newValue; //field Id wixData.update('Database', item) //Database name .then((resuls1) => { $w('#dataset1').refresh(); }); }); }); });
Try this and check if it works ->
$w("#repeater1").onItemReady( ($item, itemData, index) => { $item("#buttonmodify").onClick((event) => { $item('#boxtitle').show(); }); $item("#savetitle").onClick((event) => { let newValue = $item('#inputtitLe').value; $item('#dataset1').setFieldValue('shortTextField', newValue); $w('#dataset1').save() .then(() => { $w('#boxtitle').hide(); }); }); });