I have a submit page where you fill in information,
you click a lightbox button on that page and
then inside the lightbox you see a list of checkboxes.
On clicking those checkboxes, I want to concatenate a collection field with a string.
You can see the attempt below:
// For full API documentation, including code examples, visit http://wix.to/94BuAAs
import {ifc_data} from 'backend/ifc_data.jsw';
var picks = [];
export function checkbox1_click(event, $w) {
picks += 'compact volume';
}
export function checkbox3_click(event, $w) {
picks += 'advanced envelope';
}
$w.onReady(function () {
$w("#ifc_data").setFieldValue("strategies", picks);
});
console.log(ifc_data);
console.log(picks);
The console gives me the following error:
TypeError: $w(...).setFieldValue is not a function
From what I understood from the API regarding setFieldValue, my code should be correct.
Regarding the first comment line (// For full API documentation…)
There is an error that says “ESLint failed to validate this file because an error occurred: unknown character at position 5”.
I would be happy if someone has an idea about these two issues mentioned.
Thanks.
Hey
The function setFieldValue is a function on a dataset. You are defining ifc_data but is that a dataset or do you try to import something called that from your web modules? I would like to see the code in the web module to see if that is correct.
If you have a dataset called ifc_data you need to execute the setFieldValue inside a onDatasetReady function to make sure the dataset is loaded.
ifc_data is indeed a collection.
I tried finding onDatasetReady in the API but it doesn’t exist. Can you link to the documentation…?
Thanks.
I tried $w(“#myDataset”).onReady
The error I now get is " Error: The element selector function (usually $w) cannot be used before the page is ready"
with the code:
import {ifc_data}
from 'backend/ifc_data.jsw';
var picks = [];
export function checkbox1_click(event, $w) {
picks += 'compact volume';
}
export function checkbox3_click(event, $w) {
picks += 'advanced envelope';
}
$w("#ifc_data").onReady(function () {
$w("#ifc_data").setFieldValue("strategies", picks);
});
console.log(ifc_data);
console.log(picks);
On the one hand, the export functions need to be outside the onReady scope, on the other hand, it’s telling me something isn’t included in the onReady scope properly…