top of page
Forum Posts
Ed (Wix)
Velo Team
Mar 24, 2022
In News & Announcements
Hey Everyone,
We’ve added the ability to hide/show the number spinner on the textInput element. $w('#myTextInput').hideNumberSpinner();
$w('#myTextInput').showNumberSpinner();
let isHidden = $w('#myTextInput').numberSpinnerHidden; Check it out in the reference docs for more details.
3
1
82
Ed (Wix)
Velo Team
Jul 05, 2021
In Tips, Tutorials, Examples
We have a new tutorial to help you create Wix Bookings resources using Velo
Cunningly called Creating Bookings Resources Using Velo, this tutorial will guide you through the process of creating a new staff resource and defining their working hours.
Once you've done that, we have another tutorial to show you how to block off time in your staff's schedule. Stay tuned, as always theres more to come...
1
0
83
Ed (Wix)
Velo Team
Nov 12, 2020
In Tips, Tutorials, Examples
If you're starting out with Corvid and not sure which bits (or bytes) of code go where, check out Where Do I Put My Code. The article includes: I want to respond to button clicks and page events I want some code to run on every page Where should I put passwords and sensitive data? I want to use functions from somewhere else Where do I put Wix backend functions? Where can I handle incoming HTTP requests or webhooks? I want to run a function when my data collection changes Where do I put code for backend events? Where do I put Router code?
3
0
191
Ed (Wix)
Velo Team
Nov 04, 2020
In Tips, Tutorials, Examples
Ever wondered how to use backend events and where to put the event handler ? Check out this new article on Backend Events and all will be explained. ❗️Just remember, when testing backend events, they dont fire in preview mode.
3
0
95
Ed (Wix)
Velo Team
Oct 29, 2020
In Tips, Tutorials, Examples
Allowing your members to sign in with an existing account increases the rate of sign up. No additional passwords to remember, just click the button and you're in. Check out the new tutorial for Using SAML SSO with Corvid. If signing in with Google or Facebook is what you're after, check out the Using OAuth SSO with Corvid tutorial.
2
2
211
Ed (Wix)
Velo Team
Oct 20, 2020
In Tips, Tutorials, Examples
Ever wanted to let your site members "Sign in with Google" , or Facebook, or Twitter.... ? Allowing your members to sign in with an existing account increases the rate of sign up. No additional passwords to remember, just click the button and you're in.
Check out this new tutorial for Using OAuth SSO with Corvid and we'll show you how to do it. It's easier than you think.
6
8
861
Ed (Wix)
Velo Team
Oct 13, 2020
In Tips, Tutorials, Examples
Backend code files are useful for accessing server-based functions and also for keeping prying eyes away from sensitive code, but did you know that there are two types of backend files ? .js files are for code that is not accessible to the front end. You can't import functions into your page code from a .js file. (Well, actually you can but you’ll get a runtime error.) .jsw files are accessible to your front end, and you can import functions from them into your page code. By the way, you can import functions from a .js file into a .jsw file and call them, just don’t forget your await statement or your .then clause. Did you know that .jsw files come with permissions ? You can set the permissions for each function in your .jsw file to control who can call the function - Admin, Site member, or Anyone. To set the permissions, go to the Backend Files section of the sidebar and click on the options icon to the right of your jsw file. Select Edit Web Module Permissions. You’ll get a dialog that lets you to set the permissions for who can call each of the function in the file.
1
0
897
Ed (Wix)
Velo Team
Sep 16, 2020
In Tips, Tutorials, Examples
So you want to create a URL to an image or video that you've uploaded to the Media Manager ? The simplest way is to use a static URL like this: let imageUrl =`https://static.wixstatic.com/media/${fileName}`; Keep reading for what fileName really means. There's a bit of confusion about getFileUrl, so let's clear some things up. getFileURL gives you a download URL with a token. The token will expire after 600 minutes so if you want to get to your file after 10 hours using the returned URL, this function is not for you. The nice thing about getFileURL is that you can use it for content where you don't want to make the URL permanently available. If you want to use the link to your file for more than 10 hours you need to regenerate the URL and token, or you can use a static link as shown above.
So what is fileName ? fileName is not the name of the file in the UI of the Media Manager. The fileName that you want for your URL is a unique identifier assigned by the Media Manager when you upload a file using upload() or importFile() or getFileInfo() and can be found in the objects returned by each of these functions. If you want to see the fileName in the UI: Open the Media Manager. Select a file. Click on the down arrow next to File Info. Click Copy URL . Do a Paste somewhere to see the static URL including the filename . You'll get something like: https://static.wixstatic.com/media/81c916_38c28d77469d40419732e0667200eb48~mv2.jpeg
7
25
5k
Ed (Wix)
Velo Team
Aug 06, 2020
In Tips, Tutorials, Examples
If you have a collection that references another collection, and you want one query to retrieve data from both, use the .include() extension. Here we have a Cars collection which references the Manufacturers collection using the 'make' field. Use the name of the referencing field in a `.include()` in your query, and you get both collections returned in your results. wixData.query("Cars")
.include("make")
.find()
.then((results) => {
console.log(JSON.stringify(results.items));
});
2
0
296
Ed (Wix)
Velo Team
Jul 07, 2020
In Tips, Tutorials, Examples
Got a lot of data that you want to add to a collection ? Try using the bulkInsert function. It’s much faster than individual inserts for large amounts of data. As an example let's load historical stock price data. You can get free historical quotes from a number of sites on the net. To get some data, we'll use a backend fetch function. See the end of this post for the fetch implementation. The output of our fetch contains a prices array which looks like this: {
"prices": [
{
"date": 1562074200,
"open": 143.6999969482422,
"high": 145.63999938964844,
"low": 142.55999755859375,
"close": 144.6199951171875,
"volume": 279700,
"adjclose": 144.6199951171875
},...
]
} To use bulkInsert, your data will need to be in an array with attributes matching the name of the attributes in your collection. We have a collection called stock_quotes with the same attributes as the prices array above, plus a few more. Attributes in the collection that are not in the array are left as null. export function loadData(inputData) {
let options = {
"suppressAuth": true,
"suppressHooks": true
};
return wixData.bulkInsert("stock_quotes", inputData, options)
.then((results) => {
let response = {
"inserted": results.inserted,
"skipped": results.skipped,
"errors": results.errors
};
return response;
})
.catch((err) => {
return err
});
} Note that bulkInsert has a limit of 1000 rows so if you want to load more, you need to iterate through your input data 1000 items at a time. Tip 1: Don't iterate through your input data on the backend. If you have a lot of data, you can easily hit the timeout on calls to the backend. Tip 2: Use the options to turn off hooks and authorization to make it faster. Tip3: If update-or-insert is what you need, check out bulkSave( ) There are also bulkRemove and bulkUpdate functions. From the example, the fetch looks like this: import { fetch } from 'wix-fetch';
export function myFetch() {
return fetch("https://apidojo-yahoo-finance-v1.p.rapidapi.com/stock/v2/get-historical-data?frequency=1d&filter=history&period1=1383748200&period2=1562086800&symbol=wix", {
"method": "get",
"headers": {
"Content-Type": "application/json",
"x-rapidapi-host": "apidojo-yahoo-finance-v1.p.rapidapi.com",
"x-rapidapi-key": "000-get-a-free-api-key-000"
}
})
.then((httpResponse) => {
if (httpResponse.ok) {
return httpResponse.json();
} else {
return Promise.reject("Fetch did not succeed");
}
})
.catch((err) => {
console.log("error in fetch=", err);
return err
})
.then((dataToInsert) => {
return dataToInsert.prices;
})
}
0
1
465
Ed (Wix)
Velo Team
Jun 23, 2020
In Tips, Tutorials, Examples
If you use a dataset in read-write mode, watch out for some behaviour that you may not be expecting. When you change data in your dataset and then move to another item, your dataset will automatically save your changes without you hitting submit. To see what's happening, let’s take a common use case where we have a collection with existing data, a table to display that data, and a set of input elements below the table to allow the visitor to edit the selected row. We have buttons for Submit, and Delete, and New connected to the submit, remove, and new dataset actions. The table, the input elements and the buttons, are all connected to a read-write dataset. As the visitor clicks on each row in the table, the values of the input elements under the table are updated with the values of the selected row. The visitor can now edit the contents of a row and click submit to save the data. Our site visitor clicks on the Mercedes row and the dataset automatically populates our connected input elements with the selected row’s data. They change the Make field to “Mercedes Benz”.
Now, if they select another row in the table, the change to “Mercedes Benz” will be saved to the collection, without hitting the submit button. Why does this happen ? The input elements are connected to the dataset, so editing their contents directly updates the dataset. When the dataset’s index changes, the save() function is triggered, so any changes in the current item will be saved. Selecting another item, creating a new item, or calling setCurrentIemIndex() will cause a change to the currentItemIndex and trigger a save. So what can you do if we don't want this to happen ? The simplest option, avoiding any code, is to add an Undo button, connected to the dataset’s revert action. After the site visitor makes a change and clicks on another item, they can hit the Undo button and return the changed item to its original values. Note that one more click on the table, selecting another item, saves the change to the collection and the revert option is lost. The second option, if you don't mind a bit of coding, is to handle the submit button and input elements manually and not connect them to the dataset. There are two simple steps: Step 1. Add an on_click function to populate the input elements with the current item from the table: export function myTable_click(event) {
// populate the input elements with the values from the current item.
let currentItem = $w('#myDataset').getCurrentItem()
$w('#inputMake').value = currentItem.make;
$w('#inputModel').value = currentItem.model;
$w('#inputYear').value = currentItem.year;
} Step 2. Add an on_click function to your submit button to update the dataset and save it to the collection: export function buttonSubmit_click(event) {
let newCurrentItem={make: "", model:"", year: ""};
//get the value from the input elements
newCurrentItem.make=$w('#inputMake').value;
newCurrentItem.model=$w('#inputModel').value;
newCurrentItem.year=$w('#inputYear').value;
// set the values in the dataset and save.
$w('#myDataset').setFieldValues(newCurrentItem);
$w('#myDataset').save();
} Now the current item in the dataset is unchanged until the submit button is clicked. Selecting another item in the table simply….selects another item in the table.
1
0
586
Ed (Wix)
Velo Team
May 26, 2020
In News & Announcements
Hey All Check out the new Currency Conversion feature. All you have to do is drop the Currency Converter from the Store Elements onto your store page, choose which currencies you want to support, and the Currency Converter does the rest. You have Corvid Currencies APIs as well to get exchange rates and convert between currencies outside of your Stores page.
2
1
730
Ed (Wix)
Forum Moderator
More actions
bottom of page