top of page

Forum Posts

Salman2301
Velo Certified
Velo Certified
Feb 14, 2021
In Tips, Tutorials, Examples
Hello everyone, I am a huge fan of the custom element, I build multiple custom element in the past using js, svelte ( JS Framework ), Stencil JS (Custom element compiler). All my examples code are in Github. Anyway, I am here to show an Alert component that build using Svelte. Svelte JS is a compiler to build SPA(Single Page Application) other words Website. We can also use it to build custom element The code is Open source with MIT license https://github.com/Salman2301/wix-alert-component Example Site: https://www.test.salman2301.com/alert-web-component How to Install Easy way is to use Custom elment in Wix site is by using with Wix Block. It provide some level of IDE support. Click on this link. Follow the step to Install the Wix Block on any Wix site. Drag and Drop the Widget or Wix Block. Change the element Id to widgetAlert via the properties panel. Drag and Drop a Custom element under Add Element/Embed/Custom Element and change the Id to CustomAlert via properties panel. Click on the Custom element and select Change source. Select Server URL paste this URL https://cdn.jsdelivr.net/gh/salman2301/wix-alert-component@master/dist/index.js Set the Tag Name to alerts-component Add the following code in the page sections. // page code.js $w.onReady(function () { // This step is needed to let the Wix Block select the Custom element $w('#widgetAlert').setCustomElement($w('#CustomAlert')); // This will show Warning Alert $w('#widgetAlert').alert("This is a warning message." ) }); Note: for the alert method, You can pass a string or object // using string $w('#widgetAlert').alert("This is a alert message." ) Is same as this // using object $w('#widgetAlert').alert({ message: "This is a alert message." }) You can also pass more options like title, type of alert, wait time, style using the object method Checkout below attribute new alert $w('#widgetAlert').alert({ title: "Hello", message: "Welcome to the site." }) If you are not comfortable with Wix Block. You can just directly copy and paste the code in the public JS file To learn more check the Github Doc https://github.com/Salman2301/wix-alert-component
Build an Alert Component Using Custom Elements content media
10
6
1k
Salman2301
Velo Certified
Velo Certified
Feb 04, 2021
In Tips, Tutorials, Examples
Hello Velo users, This is a short demo on how you can create an iFrame inside a Custom element We can create iFrame using the editor by drag and droping iFrame Element but in some cases we hit limitation. cause Wix iFrame is an iFrame inside of an iFrame. Site >> iFrame ( iFrame A ) >> iFrame ( iFrame B ). iFrame A - you can't access it iFrame B - is where we can run our code.  Since we can't access the iFrame A, we lose some functionality and one of them is resizing it. This is where Custom element can help. We can use Custom element to create an iFrame and set the style to resizable And this allows the user to resize the iFrame as much as needed and push the adjacent element. Copy and paste the below code in the file public/custom-elements/<file-name>  class CustomEl extends HTMLElement { constructor() { super(); const shadow = this.attachShadow({mode: 'open'}); const iframe = document.createElement("iframe"); iframe.src="http://localhost:8080"; iframe.style = "resize:both" shadow.append(iframe)  } } customElements.define('custom-el', CustomEl); 1. Drag and Drop the Custom element under the embed section. 2. Select the File radio buttom and on the dropdown select the file name, where you pasted the code. 3. Set the tag name as custom-el 4. Publish it and open the page. It should display a iFrame that can be resized. You need to change the iframe source to the URL you want to display. in line 6. iframe.src = "<Your HTTP URL>" Notes: "resize: both" allow you to resize the iFrame, if you want to constraint vertical and horizontal resize Check this link on to use it. https://www.w3schools.com/cssref/css3_pr_resize.asp Links: Wix Editor: Adding a Custom Element to Your Site Thank you
4
1
1k
Salman2301
Velo Certified
Velo Certified
Aug 07, 2020
In Coding with Velo
August 7th, 2020 Join this week code review organized by Corvid master, Comment your code below(as per instruction) we will analyze provide you suggestion or refactored code that will be easy to read, to modify, and plenty of good practice. We also welcome experience corvid forum members to share knowledge and expertise. Instructions: *1: FULL PAGE CODE is recommended *2: Include database structure like Collection name & Field type (if you refer them in the code) 3: Is this a live site? If so, drop a link so, we can check the code. 4: Videos or Images for an explanation of what the code does is useful! Marked * are required Don'ts 1: Do NOT include any sensitive code (like passwords, secret key). // try to rewrite it as xxx if it's used inside the code const key = "XXX-XXX"; 2: Asking any questions unrelated to code review or corvid 3: Screenshot the code and not pasting the code in text format 4: Code that was not working before and asking to fix (Please create a new post in the community, This Post is dedicated to improve your current working code) Comment not related to refactoring for the code will be get deleted to organize Notes We do code review every Friday PST timezone! This post will be locked after 24 hours
0
2
75
Salman2301
Velo Certified
Velo Certified
Jul 24, 2020
In Coding with Velo
July 24th, 2020 Join this week code review organized by Corvid master, Comment your code below(as per instruction) we will analyze provide you suggestion or refactored code that will be easy to read, to modify, and plenty of good practice. We also welcome experience corvid forum members to share knowledge and expertise. Instructions: *1: FULL PAGE CODE is recommended *2: Include database structure like Collection name & Field type (if you refer them in the code) 3: Is this a live site? If so, drop a link so, we can check the code. 4: Videos or Images for an explanation of what the code does is useful! Marked * are required Don'ts 1: Do NOT include any sensitive code (like passwords, secret key). // try to rewrite it as xxx if it's used inside the code const key = "XXX-XXX"; 2: Asking any questions unrelated to code review or corvid 3: Screenshot the code and not pasting the code in text format 4: Code that was not working before and asking to fix (Please create a new post in the community, This Post is dedicated to improve your current working code) Comment not related to refactoring for the code will be get deleted to organize Notes We do code review every Friday PST timezone! This post will be locked after 24 hours (today post will be till PST 9am)
0
8
77
Salman2301
Velo Certified
Velo Certified
Jul 17, 2020
In Coding with Velo
July 17th, 2020 Join this week code review organized by Corvid master, Comment your code below(as per instruction) we will analyze provide you suggestion or refactored code that will be easy to read, to modify, and plenty of good practice. We also welcome experience corvid forum members to share knowledge and expertise. Instructions: *1: FULL PAGE CODE is recommended *2: Include database structure like Collection name & Field type (if you refer them in the code) 3: Is this a live site? If so, drop a link so, we can check the code. 4: Videos or Images for an explanation of what the code does is useful! Marked * are required Don'ts 1: Do NOT include any sensitive code (like passwords, secret key). // try to rewrite it as xxx if it's used inside the code const key = "XXX-XXX"; 2: Asking any questions unrelated to code review or corvid 3: Screenshot the code and not pasting the code in text format 4: Code that was not working before and asking to fix (Please create a new post in the community, This Post is dedicated to improve your current working code) Comment not related to refactoring for the code will be get deleted to organize Notes We do code review every Friday PST timezone! This post will be locked after 24 hours
0
0
22
Salman2301
Velo Certified
Velo Certified
Jul 10, 2020
In Coding with Velo
July 10th, 2020 Join this week code review organized by Corvid master, Comment your code below(as per instruction) we will analyze provide you suggestion or refactored code that will be easy to read, to modify, and plenty of good practice. We also welcome experience corvid forum members to share knowledge and expertise. Instructions: *1: FULL PAGE CODE is recommended *2: Include database structure like Collection name & Field type (if you refer them in the code) 3: Is this a live site? If so, drop a link so, we can check the code. 4: Videos or Images for an explanation of what the code does is useful! Marked * are required Don'ts 1: Do NOT include any sensitive code (like passwords, secret key). // try to rewrite it as xxx if it's used inside the code const key = "XXX-XXX"; 2: Asking any questions unrelated to code review or corvid 3: Screenshot the code and not pasting the code in text format 4: Code that was not working before and asking to fix (Please create a new post in the community, This Post is dedicated to improve your current working code) Comment not related to refactoring for the code will be get deleted to organize Notes We do code review every Friday PST timezone! This post will be locked after 24 hours
0
9
70
Salman2301
Velo Certified
Velo Certified
Jul 03, 2020
In Coding with Velo
July 3rd, 2020 Join this week code review organized by Corvid master, Comment your code below(as per instruction) we will analyze provide you suggestion or refactored code that will be easy to read, to modify, and plenty of good practice. We also welcome experience corvid forum members to share knowledge and expertise. Instructions: *1: FULL PAGE CODE is recommended *2: Include database structure like Collection name & Field type (if you refer them in the code) 3: Is this a live site? If so, drop a link so, we can check the code. 4: Videos or Images for an explanation of what the code does is useful! Marked * are required Don'ts 1: Do NOT include any sensitive code (like passwords, secret key). // try to rewrite it as xxx if it's used inside the code const key = "XXX-XXX"; 2: Asking any questions unrelated to code review or corvid 3: Screenshot the code and not pasting the code in text format 4: Code that was not working before and asking to fix (Please create a new post in the community, This Post is dedicated to improve your current working code) Comment not related to refactoring for the code will be get deleted to organize Notes We do code review every Friday PST timezone! This post will be locked after 24 hours
2
2
42
Salman2301
Velo Certified
Velo Certified
Jun 26, 2020
In Coding with Velo
June 26th, 2020 Join this week code review organized by Corvid master, Comment your code below(as per instruction) we will analyze provide you suggestion or refactored code that will be easy to read, to modify, and plenty of good practice. We also welcome experience corvid forum members to share the knowledge and expertise. Instructions: *1: FULL PAGE CODE is recommended *2: Include database structure like Collection name & Field type (if you refer them in the code) 3: Is this a live site? If so, drop a link so, we can check the code. 4: Videos or Images for explanation of what the code does is useful! Marked * are required Don'ts 1: Do NOT include any sensitive code (like passwords, secrect key). // try to rewrite it as xxx if it's used inside the code const key = "XXX-XXX"; 2: Asking any questions unrelated to code review or corvid 3: Screenshot the code and not pasting the code in text format 4: Code that was not working before and asking to fix (Please create a new post in the community, This Post is dedicated to improve your current working code) Comment not related to refactor for the code will be get deleted to organize Notes We do code review every friday PST timezone! This post will be locked after 24 hours
1
5
70
Salman2301
Velo Certified
Velo Certified
Jun 19, 2020
In Coding with Velo
June 19th, 2020 Join this week code review organized by Corvid master, Comment your code below(as per instruction) we will analyze provide you suggestion or refactored code that will be easy to read, to modify, and plenty of good practice. We also welcome experience corvid forum members to share the knowledge and expertise. Instructions: *1: FULL PAGE CODE is recommended *2: Include database structure like Collection name & Field type (if you refer them in the code) 3: Is this a live site? If so, drop a link so, we can check the code. 4: Videos or Images for explanation of what the code does is useful! Marked * are required Don'ts 1: Do NOT include any sensitive code (like passwords, secrect key). // try to rewrite it as xxx if it's used inside the code const key = "XXX-XXX"; 2: Asking any questions unrelated to code review or corvid 3: Screenshot the code and not pasting the code in text format 4: Code that was not working before and asking to fix (Please create a new post in the community, This Post is dedicated to improve your current working code) Comment not related to refactor for the code will be get deleted to organize Notes We do code review every friday PST timezone! This post will be locked after 24 hours
1
16
136
Salman2301
Velo Certified
Velo Certified
Jun 12, 2020
In Coding with Velo
June 12th, 2020 Join this week code review organized by Corvid master, Comment your code below(as per instruction) we will analyze provide you suggestion or refactored code that will be easy to read, to modify, and plenty of good practice. We also welcome experience corvid forum members to share the knowledge and expertise. Instructions: *1: FULL PAGE CODE is recommended *2: Include database structure like Collection name & Field type (if you refer them in the code) 3: Is this a live site? If so, drop a link so, we can check the code. 4: Videos or Images for explanation of what the code does is useful! Marked * are required Don'ts 1: Do NOT include any sensitive code (like passwords, secrect key). // try to rewrite it as xxx if it's used inside the code const key = "XXX-XXX"; 2: Asking any questions unrelated to code review or corvid 3: Screenshot the code and not pasting the code in text format 4: Code that was not working before and asking to fix (Please create a new post in the community, This Post is dedicated to improve your current working code) Comment not related to refactor for the code will be get deleted to organize Notes We do code review every friday PST timezone! This post will be locked after 24 hours
0
15
174
Salman2301
Velo Certified
Velo Certified
Jun 05, 2020
In Coding with Velo
June 5th, 2020 Join this week code review organized by Corvid master, Comment your code below(as per instruction) we will analyze provide you suggestion or refactored code that will be easy to read, to modify, and plenty of good practice. We also welcome experience corvid forum members to share the knowledge and expertise. Instructions: *1: FULL PAGE CODE is recommended *2: Include database structure like Collection name & Field type (if you refer them in the code) 3: Is this a live site? If so, drop a link so, we can check the code. 4: Videos or Images for explanation of what the code does is useful! Marked * are required Don'ts 1: Do NOT include any sensitive code (like passwords, secrect key). // try to rewrite it as xxx if it's used inside the code const key = "XXX-XXX"; 2: Asking any questions unrelated to code review or corvid 3: Screenshot the code and not pasting the code in text format 4: Code that was not working before and asking to fix (Please create a new post in the community, This Post is dedicated to improve your current working code) Notes We do code review every friday PST timezone!
2
17
127
Salman2301
Velo Certified
Velo Certified
May 29, 2020
In Coding with Velo
May 29th, 2020 Join this week code review organized by Corvid master, Comment your code below(as per instruction) we will analyze provide you suggestion or refactored code that will be easy to read, to modify, and plenty of good practice. We also welcome experience corvid forum members to share the knowledge and expertise. Instructions: *1: FULL PAGE CODE is recommended *2: Include database structure like Collection name & Field type (if you refer them in the code) 3: Is this a live site? If so, drop a link so, we can check the code. 4: Videos or Images for explanation of what the code does is useful! Marked * are required Don'ts 1: Do NOT include any sensitive code (like passwords, secrect key). // try to rewrite it as xxx if it's used inside the code const key = "XXX-XXX"; 2: Asking any questions unrelated to code review or corvid 3: Screenshot the code and not pasting the code in text format 4: Code that was not working before and asking to fix (Please create a new post in the community, This Post is dedicated to improve your current working code) Notes We do code review every friday PST timezone! This post will be locked after 24 hours
2
11
160
Salman2301
Velo Certified
Velo Certified
May 22, 2020
In Coding with Velo
May 22nd, 2020 Join this week code review organized by Corvid master, Comment your code below(as per instruction) we will analyze provide you suggestion or refactored code that will be easy to read, to modify, and plenty of good practice. We also welcome experience corvid forum members to share the knowledge and expertise. Instructions: *1: FULL PAGE CODE is recommended *2: Include database structure like Collection name & Field type (if you refer them in the code) 3: Is this a live site? If so, drop a link so, we can check the code. 4: Videos or Images for explanation of what the code does is useful! Marked * are required Don'ts 1: Do NOT include any sensitive code (like passwords, secrect key). // try to rewrite it as xxx if it's used inside the code const key = "XXX-XXX"; 2: Asking any questions unrelated to code review or corvid 3: Screenshot the code and not pasting the code in text format 4: Code that was not working before and asking to fix (Please create a new post in the community, This Post is dedicated to improve your current working code) Notes We do code review every friday PST timezone! This post will be locked after 24 hours
0
5
93
Salman2301
Velo Certified
Velo Certified
May 15, 2020
In Coding with Velo
May 15th, 2020 Join this week code review organized by Corvid master, Comment your code below(as per instruction) we will analyze provide you suggestion or refactored code that will be easy to read, to modify, and plenty of good practice. We also welcome experience corvid forum members to share the knowledge and expertise. Instructions: *1: FULL PAGE CODE is recommended *2: Include database structure like Collection name & Field type (if you refer them in the code) 3: Is this a live site? If so, drop a link so, we can check the code. 4: Videos or Images for explanation of what the code does is useful! Marked * are required Don'ts 1: Do NOT include any sensitive code (like passwords, secrect key). // try to rewrite it as xxx if it's used inside the code const key = "XXX-XXX"; 2: Asking any questions unrelated to code review or corvid 3: Screenshot the code and not pasting the code in text format 4: Code that was not working before and asking to fix (Please create a new post in the community, This Post is dedicated to improve your current working code) Notes We do code review every friday PST timezone! This post will be locked after 24 hours
0
16
111
Salman2301
Velo Certified
Velo Certified
May 08, 2020
In Coding with Velo
May 8th, 2020 Join this week code review organized by Corvid master, Comment your code below(as per instruction) we will analyze provide you suggestion or refactored code that will be easy to read, to modify, and plenty of good practice. We also welcome experience corvid forum members to share the knowledge and expertise. Instructions: *1: FULL PAGE CODE is recommended *2: Include database structure like Collection name & Field type (if you refer them in the code) 3: Is this a live site? If so, drop a link so, we can check the code. 4: Videos or Images for explanation of what the code does is useful! Marked * are required Don'ts 1: Do NOT include any sensitive code (like passwords, secrect key). // try to rewrite it as xxx if it's used inside the code const key = "XXX-XXX"; 2: Asking any questions unrelated to code review or corvid 3: Screenshot the code and not pasting the code in text format 4: Code that was not working before and asking to fix (Please create a new post in the community, This Post is dedicated to improve your current working code) Notes We do code review every friday PST timezone! This post will be locked after 24 hours
0
7
77
Salman2301
Velo Certified
Velo Certified
May 01, 2020
In Coding with Velo
May 1st, 2020 Join this week code review organized by Corvid master, Comment your code below(as per instruction) we will analyze provide you suggestion or refactored code that will be easy to read, to modify, and plenty of good practice. We also welcome experience corvid forum members to share the knowledge and expertise. Instructions: *1: FULL PAGE CODE is recommended *2: Include database structure like Collection name & Field type (if you refer them in the code) 3: Is this a live site? If so, drop a link so, we can check the code. 4: Videos or Images for explanation of what the code does is useful! Marked * are required Don'ts 1: Do NOT include any sensitive code (like passwords, secrect key). // try to rewrite it as xxx if it's used inside the code const key = "XXX-XXX"; 2: Asking any questions unrelated to code review or corvid 3: Screenshot the code and not pasting the code in text format 4: Code that was not working before and asking to fix (Please create a new post in the community, This Post is dedicated to improve your current working code) Notes We do code review every friday PST timezone! This post will be locked after 24 hours
1
3
98
Salman2301
Velo Certified
Velo Certified
Apr 24, 2020
In Coding with Velo
April 24, 2020 Join this week CODE REVIEW organized by Corvid Master, Comment your code below(as per instruction), we will analyse, give you suggestions, refactor code that will be easy to read, potential future modifications and plenty of good practices. We also welcome experienced corvid forum member to share their knowledge and expertise! Instructions: 1. What type of code review do you want?(Required) Refactoring: Want the code to be more readable and scalable? Performance: Want to improve the performance? Discussion: About database structure, page structure and other corvid tools . 2. Kindly include database structure, collection name & field type (if you refer them in the code). 3. Is this a live site? If so, send us the link. 4. Videos or images for explanation are always welcome. 5. Feel free to paste your code in gist or jsfiddle and share the link on your comment. Don'ts : 1. Do NOT include any sensitive code (like passwords, secretkey). // try to rewrite it as xxxx if it's used inside the code const key = "XXXX-XXXX"; Note: We do Code Review EVERY FRIDAY(Pacific Time)! This post will locked after 24 hours.
2
25
154
Salman2301
Velo Certified
Velo Certified
Dec 22, 2019
In Coding with Velo
This is almost the exact sample wix-crm doc provide I am running this code when http endpoint is trigger using wix-http module so, when a zapier hit the http-function URL in http-function.js it will run insContact function in contact.jsw file all the data are been send to contact.jsw file but still there is the error. Error => "Bad Request: please check the user inputs." Logs code // contact.js import wixCrm from 'wix-crm-backend'; export async function insContact(user) { try { console.log("ins Contact : " , user); let {firstName, lastName, email} = user; let contact = { "firstName": firstName, "lastName": lastName, "emails": [email] } console.log("Contact : " , contact); let contacted = await wixCrm.createContact(contact); console.log("contacted : ", contacted) return contacted; } catch (err) { console.log("Error : " , err.message); } }
Wix-crm-backend is not working? content media
0
3
334
Salman2301
Velo Certified
Velo Certified
Nov 24, 2019
In Coding with Velo
If.you are like me, working at night or starring screen for hours straight to write codes and also wanna take care of your health. I would highly recommend this extension which I have been using for a week. I created this extension for myself as corvid doesn't support the dark theme. I give this extension to some of my Wix partners and they loved it. All the code is available to edit and commented so, you can change different color which works best for you have fun playing with it. :) I have some other future plan 1. able to change site structure and database color to dark 2. have a dropdown to select different theme/ color, so anyone can change the color. 3. able to increase the font size (i try to increase using CSS but it didn't work). 4. able to change the color of the selected text and indentation line ( i can't select the indentation using the chrome dev tools, therefore I can't get the class name to manipulate the element.) and I hope you like it too. take care  :) Install link: https://www.salman2301.com/mytheme
Corvid darkmode - code editor theme content media
8
8
386
Salman2301
Velo Certified
Velo Certified
Dec 03, 2018
In Coding with Velo
Now with the help of npm we can easily create a PDF using pdf generator api A PDF is created and downloaded when the user submited a form. Usage: Create a Invoice, Create a certificate for the user etc. Sample Website link Requirement: 1. Free account in pdfgeneratorapi Overall Layout: i) PDF GENERATOR API ii) Wix code Backend (npm - pdf-generator-api) iii)Page Code iv) HTML Embed code (Convert Base64 into PDF file) i) PDF GENERATOR API 1. Goto pdfgeneratorapi 2. Sign In and goto Dashboard 3. Select the "Template" on the left side bar 4. Click on the "New Template" button, A new window open to edit the pdf File 5. Design the PDF and to create a variable use open and close Curly brackets as shown on this image [This is a image of the pdf generator Editor {Name} where the variable will be later assign using wix code And there is one more variable,{Detail} to add the message] 6. Publish the template and Goto the "Templates" from the Dashboard 7. Copy the Template Id from the "Templates" 8. Copy the APIKey and APISecret from the "Account Settings" 9. Copy the WorkSpace Identifier from the "Admin Panel" ii) Wix code Backend 1. Search and Install "pdf-generator-api" npm (Check this link for Installation guide and Node package manager npm) 2. Create a Backend Web Module "pdf.jsw". 3. Copy and paste the code // Code start import PDFGeneratorAPI from 'pdf-generator-api'; export async function pdf(name, detail) { let Client = new PDFGeneratorAPI( '<APIkey>', '<APISecrect>' ); Client.setWorkspace('<WorkSpace identifier>'); let obj = { "Name" : name, "Detail" : detail, } let response = await Client.output('<Template Id>', obj) return response.response } // Code end 4. Replace the <APIkey> , <APISecrect> , <WorkSpace identifier> and <Template Id> to your corresponding value grab from the pdfgeneratorapi site 5. Create a object for the variable in this case i have create an object "obj" with two Key "Name" and "Detail" and the corresponding value directly from the parameter of this async function "name" and "detail" iii)Page Code 1. Drag and drop Input element, Text box element and Button in a new page 2. Also Drag and drop the "HTML embed" element from "more" section 3. Change the Property name as shown in the image 4. Copy and paste the below code // Code start import { pdf } from 'backend/pdf.jsw'; $w.onReady(function () { var base64; $w('#btnSubmit').onClick(() => { let name = $w('#inName').value; let detail = $w('#inDetail').value; pdf(name, detail).then(e => { base64 = e; base64 = 'data:application/pdf;base64,' + base64 let msg = { "conv": true, "dataUrl": base64 } $w('#html1').postMessage(msg); }); }); }); // Code end iv) HTML Embed code 1. Click on the HTML embed element 2. Click on "Edit code" button 3. Paste the following code [updated 02-dec-2018] <!-- code start --> <script> window.onmessage = event => { if(event.data.conv) { if(document.getElementById('Download') === null || document.getElementById('Download') === undefined){ var pn = document.createElement('a') pn.download = 'Download.pdf'; pn.title = 'Download pdf document'; pn.textContent = 'Download'; pn.id ='Download' var s = document.getElementsByTagName('body')[0].appendChild(pn); pn.href = event.data.dataUrl; } else { let d = document.getElementById('Download') d.href = event.data.dataUrl; } document.getElementById('Download').click() } } </script> <!-- code end --> Overall codes Congrats! That's it Original post : https://www.salman2301.com/forum/wix-code-advance/create-pdf-using-wix-code-and-pdf-generator-api Let me know if you have any questions
PDF GENERATOR API npm demo content media
6
24
6k

Salman2301

Velo Certified
Content Creator
Velo Expert
+4
More actions
bottom of page