4

I am just taking my first steps to assist with some Google Maps integration on a Wix-generated website.

I have enabled "Velo developer mode" and opened the JavaScript editor panel.

When I enter the code document.createElement('div') the editor shows an error message against the line, " 'document' is not defined"

I have a lot to learn about Wix, I guess. Why is the editor complaining at this most basic of references?

enter image description here

Bob Arnson
  • 21,377
  • 2
  • 40
  • 47
Basil Bear
  • 433
  • 3
  • 15

3 Answers3

1

Wix Velo does give you direct access to the DOM, as noted in Sam's answer. Instead, you need to use Wix's $w namespace. For more information, you can check out the docs here (https://www.wix.com/velo/reference/$w).

yadavta
  • 11
  • 1
  • 1
0

When using Velo by Wix, you do not have direct access to the DOM. Therefore, you can't use the document object.

Depending on what you're trying to accomplish with document.createElement, you might want to use the Velo collapse() function or use a Repeater element.

Sam
  • 886
  • 1
  • 5
  • 8
0

Currently using Wix you cannot create element using the code editor directly.

You can drag and drop the element from the editor and interact with the element using the API Wix documentation.

If you want to use your own Map element drag and drop an IFrame element Where you can access the DOM and you can talk to host site from the IFrame from PostMessage and listen for the message using onMessage Wix documentation

You can also use Custom Element get access to DOM and create your Map element

That said Wix have there own map element but it has some limitation currently

tl;dr To create your map element or access Dom

  1. Use Wix Map element
  2. Use IFrame
  3. Use Custom element
Salman
  • 892
  • 12
  • 13