Adding Custom Code to your Editor X Website
Tags: tutorial, tooling, webdev, beginners
Published: 2022-04-17 13:35:00

**Disclaimer: This post is sponsored by Editor X.**

## **Table of Contents**

[Introduction](#introduction)
[Adding Custom Code](#1)

   [1. SignIn to Editor X](#2)
   [2. Use Blank Canvas or Select a Template](#3)
   [3. Dev Mode](#4)
   [4. Element IDs](#5)
   [5. Default Values setup](#6)
   [6. Event Handlers](#7)
   [7. Code addition](#8)


[Conclusion](#conclusion)

<hr>

## **Introduction** <a name="introduction"></a>

For the longest time, I was intrigued by how you could just make a fully functional website without using any code at all.  Hence, in order to satiate my curiosity, I've finally joined the low-code/no-code gang as well (not permanently though). 

The tool that caught my interest was **Editor X**. I already wrote an article explaining what it is and why should you bother with it. If you want to read it, you can do that [here](https://thecodingcompany.hashnode.dev/how-to-make-a-fully-responsive-website-without-html-css-or-javascript).

But if you've already read it, then you might remember that I mentioned how you could add custom code to your Editor X websites. Well, today I'll teach you how to do it so that you can spice up your websites ;)

<hr>

## **Adding Custom Code** <a name="1"></a>

Now, let's get to the main topic. We can divide this in steps so that it will be easy for you guys to understand!

### **1. SignIn to Editor X** <a name="2"></a>

First of all, you gotta register or login to EditorX. You can do that here: 

www.editorx.com/editor-x/ayesha

Once you login, you'll see this screen:


![01.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1648359766740/DKg3RVsWs.png)

But, right after signing up or clicking on the "create new site" button, you'll see this screen:

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1648359860257/3oK-3kw07.png)

### **2. Use Blank Canvas or Select a Template** <a name="3"></a>

Now, as shown in the picture shared in the last section, select what type of site you want to make.

I ended up selecting "Restaurant and Food" since it's no secret I'm a big foodie ;)

You have two options. Either choose a blank canvas and work from scratch or select a template. Since your truly is truly busy these days, I chose a template.

![03.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1648359988772/N3XU40jwM.png)

If you are here from twitter, you might know that I already made a pretty website for my favourite food 😆

Here it is:

https://ayeshasahar.editorx.io/creamyland

For conveniance purposes, rather than creating a new one, I'll be showing you how to add code to this one. If you are a beginner and wanna practice along, just choose any template as all are really beautiful!

### **3. Dev Mode** <a name="4"></a>

So let's talk business. I'll keep this really simple. 

There are two modes you can work with. One is the simple mode and one is dev mode. The main difference between these two is that in simple mode you can't add any code but in dev mode, you can!

I'd recommend that you choose your working mode based on your occupation. 

**You should choose simple mode if you are a:**

✅ Designer who wants to make their designs come to life

✅ Developer who loves/prefers no-code

✅ Developer who is working on multiple projects

✅ person who hasn't coded or designed anything in their entire life

**You should choose dev mode if you are a:**

✅ Developer who wants to spice up their website 

✅ Developer who loves/prefers low-code

✅ Developer who wants to build complex web applications

The dev mode is official called "Velo Dev Mode". It is a full-stack development solution that allows you to extend the functionality of your Editor X sites by adding code.
You can add custom functionality using JavaScript and Velo APIs in both the frontend and backend.

Anyways, returning to the topic. Since we want to add code, we will choose dev mode.

After selecting your site, you will be taken to this page. Just select dev mode as I've marked in this pic.

![0004.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1648362793533/xLqmonBQ8.png)

Here's what dev mode looks like:

![00005.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1648364059063/V5vdG4SaV.png)

I color coded the side panel to let you guys know what each icon is for. 

👉 The green one shows the UI or what the user deals with.

👉 The pink one lets you work on the backend. If you are not a backend dev, I'd suggest not to make changes here.

👉 The yellow one lets you search your code.

👉 The purple one is for managing databases.

👉 The blue one shows develeloper tools.

### **4. Element IDs** <a name="5"></a>

Once you select anything, you'll find out that it has a unique id. This id can be changed too. Iyt can be done from the box I've highlighted yellow.

![006.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1648364886787/X18FRQNqt.png)

### **5. Default Values setup** <a name="6"></a>

You can even set the default state of the element selected. The default state is how you want that element to behave once the page loads.

![007.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1648365043851/7AhmEBmz-.png)
 
### **6. Event Handlers** <a name="7"></a>

Right below the default values option is the event handlers option. The event handlers are quite similar to the ones in JavaScript.

![008.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1648365126689/7C9mItMup.png)

You can add these to create custom interactions based on your visitor's behaviors. 

We'll use the "onClick()" event handler to just change some text once a button is clicked. 

### **7. Code addition** <a name="8"></a>

Now, what I wanna do is to change the "Eat Ice-Cream, Eat Cakes, Be Happy!" text when I click the "click me" button. So, to do that, first of all I will select the click me button and then select the "onClick()" event handler.

![finale.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1648473182982/wctaOmu49.png)

A function will be added in the code panel just like shown in the picture above. You can type your javascript inside this function.

Since I wanna be able to change to change text when clicked on this button, here's what I'll add:


```js
export function button3_click(event) {
	// This function was added from the Properties & Events panel. To learn more, visit http://wix.to/UcBnC-4
	// Add your code for this event here: 
	$w('#text30').text ="Let me tell you a secret, Ice Cream Solves Everything!"
}
``` 

"# text30" is the unique of "Eat Ice-Cream, Eat Cakes, Be Happy!" text. The code here means that once this button is clicked, just set the text equal to "Let me tell you a secret, Ice Cream Solves Everything!".

Here's how it works:


![main_AdobeCreativeCloudExpress.gif](https://cdn.hashnode.com/res/hashnode/image/upload/v1648473970813/ZIJrzagXF.gif)

**P.S:** Sorry for the bad gif quality, you can get the real experience here ;)

https://ayeshasahar.editorx.io/creamyland

<hr>

## **Conclusion** <a name="conclusion"></a>

Hope you understood how it works! I just gave you a simple example so that everyone can understand and try it out. You guys can do so much more than this.

After working with Editor X, I realized how convenient low-code/no-code tools are. Everyone should try at least one such tool. It was a good experience for me and I hope that it would be the same for you guys as well :)

<hr>

**Let's connect!**

✨ [Twitter](https://twitter.com/IAyeshaSahar)  

✨ [Github](https://github.com/AyeshaSahar)