Hi All, can we apply the backend code on lightBox?
Not fully sure what you mean by this?
What backend code?
Hey @ppremkumar055!
Yep, you can write functions in backend code, and then import them into page code (including lightboxes).
Take a read over this doc to understand how backend code works - https://www.wix.com/velo/reference/getting-started/writing-backend-code
Hi Simen, backend code from Public or Backend ( .js or .jws files). Can we use these files on the Lightbox?
You can’t import .js files to frontend (page code/lightbox) you can only import functions in .js files within backend files if it’s created in backend.
You can create .jsw files to export functions and import exported functions to frontend/lightbox code.
myModule.jsw:
export function example(x, y) {
return x * y;
}
Lightbox Code:
import { example } from 'backend/myModule.jsw';
$w.onReady(() => {
example(5, 5)
.then((result) => {
console.log(result);
})
})
If that’s helped don’t forget to mark answer/s as solution.