top of page
Forum Posts
jay.johnson
Dec 18, 2019
In Coding with Velo
Is there a way to turn off the “auto suggest/help feature” (not sure what it is called...seems like it might be MDN Help related) in the Corvid editor (see attached screen shot)? I have so much code it is really bogging down my editor (not to mention that it is making it very difficult to edit as these little annoying popups keep showing up). Any advice would be most appreciated. (I realize this could be a browser issue...but it is killing the performance of my Corvid editor. I am using Chrome.) Thanks in advance!!!
0
0
20
jay.johnson
Aug 21, 2019
In Coding with Velo
I have this simple front-end function xyz that calls a backend query function (with all of the appropriate import statements and onReady sections and such): async function xyz() {
let tempProd = await get_my_product("Prod_04");
let myNewVariable = tempProd.price;
} My backend query function looks like this: export async function get_my_product(prodId) {
return wixData.query("products")
.eq("productId", prodId)
.limit(1)
.find()
.then((results) => {
let prodItems = results.items;
return (prodItems[0]);
})
.catch((error) => {
let errorMsg = error.message;
myLog("My Product Query Error Msg/Code = " + errorMsg)
});
} This works "almost" all of the time (actually I have dozens of these back-end query functions and maybe hundreds of the front-end function calls to them throughout my system). I am pretty sure the basic format is correct since my system works in general, however I think that I am missing something related to Promises or back-end timeouts. Several times per day, when the internet seems to slow down, my testers run into the following error from the front end: Uncaught (in promise) TypeError: Cannot read property 'price' of undefined I am guessing this is thrown because the Promise is not being resolved and my guess is that it is because the Backend Server and/or the DB server is not responding and is timing out based on the following back-end myLog data I am collecting. My Product Query Error Msg/Code = WDE0028: Request timed out. / WD_REQUEST_TIMED_OUT My question is how do I best trap this in my code and what is the best course of action if this happens? Should I trap it in the front-end code or in the back-end code? I need to keep trying until the back-end servers give me a response. How should I best do this? Any advice would be most appreciated! Thanks, Jay
0
2
729
jay.johnson
Apr 12, 2019
In Coding with Velo
I have several repeaters set to load in a function called from the on.Ready function. Each repeater was pre-loaded with ONE default item from the editor. I query the DB and get some data, then loop to incrementally populate this into the repeaters. Upon execution the following occurs in this order (on my page and Developers Console) 1) The NEW correct data is briefly displayed in the repeater 2) The console.log statement in the myRepeaterLoadFunction does not display (understandable if the "backend" code rendering cycle is what is running) 3) Then AFTER the "finished hydrate" message displays in the Developers Console (which I
assume signals that the "backend" code has finished), the console.log statement prints
correctly with all of my new data for each repeater from the for loop calls. 4) However, the repeater display immediately reverts back to the single default data record
that was loaded from the editor as soon as the code finishes executing (after the last
console.log statement is written.) Seems like a rendering issue to me. It is like the "backend" code rendering works properly, but then the "browser" rendering cycle is resetting something. I have tried wrapping the query (as well as the for statement) in if (wixWindow.rendering.renderCycle === 1) {....}
if (wixWindow.rendering.env === "backend") {....} using various combinations of renderCycle= (1,"1",2,"2") and env=("backend" and "browser"). It seems logical that this could be the issue, but nothing fixes this, I am stumped. Anyone have any suggestions? Any help would be most appreciated.... $w.onReady(async function () {
let myItems = await getSomeData(); // contains repeater names and variables
for (var i = 0, len = myItems.length; i < len; i++) {
let status = await myRepeaterLoadFunction(myItems[i]);
console.log("Status= " + status)
}
}); async function myRepeaterLoadFunction(myItem) {
let newIdNum = await getIdNum(); //function to get random id num - starts with "PBP"
// Build New Repeater data element for insertion
const tempRptrData = [{
"_id" : newIdNum,
"image" : myItem.inputSrc,
"displayValue" : myItem.inputDesc
}];
$w("#" + myItem.repeaterName).onItemReady(($item, itemData, index) => {
$item("#" + myItem.sourceVarName).src = itemData.image;
$item("#" + myItem.descVarName).text = itemData.displayValue;
});
let tempData = $w("#" + myItem.repeaterName).data;
if (tempData[0]._id.substring(0, 3) !== "PBP") { tempData.splice(0, 1) } // delete 1st record
$w("#" + myItem.repeaterName).data = tempData.concat(tempRptrData);
console.log("MyRptrData = ",$w("#" + myItem.repeaterName).data); // displays correct data!
return "success";
}
0
0
112
jay.johnson
Apr 01, 2019
In Coding with Velo
The following snippet (executed from a lightbox) is intended to send a triggered confirmation email to the logged-in user with regarding a particular action on the site. (This is working.) // Get current logged in user
let user = wixUsers.currentUser;
userId = user.id;
// Send email confirmation to the logged in user
wixCRM.emailContact("RMabc", userId) //<-THIS WORKS
.then(() => {
//Get list of others from db collection that need a notification email
get_va_list().then((vaList) => {
for (var i = 0, len = vaList.length; i < len; i++) {
console.log("vaList[i].vaContactId = ", vaList[i].vaContactId)
wixCRM.emailContact("RMxyz", vaList[i].vaContactId) //<-THIS DOES NOT WORK
.then(() => {console.log("All Emails sent");})
.catch((err) => {console.log("Email Error = " + err);});
}
wixWindow.lightbox.close("success");
});
})
.catch((err) => {console.log("Email Error = " + err); });
I then also want to send another triggered email to a small list of three other site members that the action took place. (Shown above in the second wixCRM.emailContact call.) This is not working. I have gathered a list of the three contact_id's when they were created and stored them in a collection for retrieval here. (They appear to be retrieving correctly and are correctly stored in the vaList[i].vaContactId variable as proven by the console.log output. I have compared each with the userId obtained upon registration (not the collection ID when stored in the db) when they were created elsewhere in my code and they appear to be stored/retrieved correctly.) When the code tries to send this second set of emails, I get the following error. There are three emails in my list.
(3)POST https://www.mywebsite.com/_api/shoutout/v1/emailContact 401 (Unauthorized)
Uncaught (in promise) Failed to execute 'postMessage' on 'Worker': function Sb(){return!1} could not be cloned. I need this second set of emails to be sent whenever any site member performs this action (regardless of the permissions of the logged in user.) I also tested the code, "RMxyz" with the logged in user just to ensure the triggered email was properly configured and it sent properly. Any thoughts on what I could be doing wrong? I would be most appreciative of any advice!
0
0
43
jay.johnson
Mar 30, 2019
In Coding with Velo
When a new user registers for my site, I would like to capture their email address. I thought I had done this in the past and it has worked perfectly. Now it seems something has changed. Below is 100% of the code I put on a test site with one single blank "members" page. When the page loads (after successful registration by the user), the "currentUser" is not found. If I simply refresh the screen, the "currentUser" is found. The performance is the same for me on Chrome and Safari (for both "open access" and "incognito"access"). Could this have something to do with Wix multi-stage "onReady" processing? Do I need to find some way to force "onReady" to run twice? I would be most appreciative if someone could try this very simple snippet and tell me if it is working or if I have missed something obvious. Thanks! import wixUsers from 'wix-users';
$w.onReady(async function () {
let user = wixUsers.currentUser;
user.getEmail().then((email) => {
console.log("Found User= " + email); //<-Works on screen refresh only
})
.catch((error) => {
console.log("No User Found error= " + error) //<-Errors out on initial page load
});
});
0
4
58
jay.johnson
Feb 13, 2019
In Coding with Velo
Variable scoping continues to confound me (see my sample code below). I have three questions for my understanding, however, the bottom line is that I need metricsArray available in Position4 for further processing. Q1: I have initialized the "metricsArray" array variable at the top of my function which I thought meant it had global scope in the entire function...is this correct? I have tried both let and var statements and neither change the results below. Q2: If I try setting the return variables from myFunction (metricsArray_A and/or metricsArray_B) below to metricsArray, then I get a warning that the variable is already declared in the upper scope indicating that I am doing something incorrect. Regardless of the warning, Position1 is the only situation where the metricsArray contains data. Also, if I comment out the initialization line of code at the top of the function, then Position2, Position3 and Position4 all complain that metricsArray is not defined. Where should metricsArray be declared? Q3: From the console.log, the only Position that contains data in the metricsArray variable is Position1. In other words, it appears to me that the global scope is not being held. What am I doing wrong? Any advice would be most appreciated. I will buy a virtual doughnut and a cup of coffee for anyone that can help me out here! Thanks, Jay ----------------------------------------- async function initalizeMetrics(secArr) {
let metricsArray = [];
//Main Loop
secArr.forEach(async function (sec) {
await getSection(sec).then((text) => {
let newSection = sec.replace(/Upd/, "Orig")
//////// Call myFunction and return metricsArray_A
myFunction(sec, text).then((metricsArray_A) => {
console.log("metricsArray_A = " + metricsArray_A)
})
//////// Call myFunction and return metricsArray_B
myFunction(newSection, text).then((metricsArray_B) => {
console.log("metricsArray_B = " + metricsArray_B)
metricsArray = metricsArray_B;
console.log("Position1 - metricsArray = " + metricsArray) // <-Has data
})
console.log("Position2 - metricsArray = " + metricsArray) // <-Empty
})
console.log("Position3 - metricsArray = " + metricsArray) // <-Empty
});
console.log("Position4 - metricsArray = " + metricsArray) // <-Empty
}
0
3
696
jay.johnson
Jan 15, 2019
In Coding with Velo
I have a trivial piece of code on a trivial page that works in Preview mode, but does not work once my page is published. I have a Strip with two columns (column1 and column2). I have a button (hideShow) with the code below tied to it (outside of the strip). //---------------------------------------------- $w.onReady(function () {})
export function hideShow_click(event) {
if ($w("#column1").collapsed) {
$w("#column1").expand();
} else {
$w("#column1").collapse();
}
}
//---------------------------------------------- In Preview mode column1 collapses and expands as expected (with column2 expanding to fill the strip). When I publish the page, column1 just "hides" and "shows" (that is it does not "collapse" and "expand"). Any help would be most appreciated. (I have tried in both "stretch" and "page" modes for the strip...same behavior.) Thanks in advance! Jay
1
6
442
jay.johnson
Dec 15, 2018
In Coding with Velo
I have a seemingly pretty simple requirement that I cannot figure out. Using Wix Code, I need to format a text string inside a repeater with two different colors. I want the repeated sentence below to be black with the exception of the word "red", which I want to be red. $w("#repeater1").onItemReady( ($item, itemData, index) => {
repeatedText = $item("#text225");
$item("#text225").text = "The car is red."
$item("#text225").html= "<span style='color:#000000; ' >" + $item("#text225").text.substring(0,11) + "</span>" + "<span style='color:#FF1F00; ' >" + $item("#text225").text .substring(11,15) + "</span>"; repeatedText.text = $item("#text225").text; }
When I run this, it appears that only the first <span> is being used and the entire sentence is black. If I switch the order of the colors, then the entire sentence is red. I have also checked the substring parameter here by commenting out the first and then the second <span> and the repeater displays correctly as either "The car is" or as "red.", respectively as it should, but only the color from the first <span> being used. One other point in terms of full disclosure...I have $w("#repeater1") (NOT the text field inside the repeater) tied to a dataset. It appears to be displaying the number of items in the data set correctly as well as overwriting the text field of #text225 correctly with "The car is red." I am probably missing something really simple here, but I just cannot figure it out. Any advice from a Wix HTML guru on how to pull this off would be most appreciated! Thanks, Jay
0
2
960
jay.johnson
Nov 27, 2018
In Coding with Velo
Can't believe I am stuck on this (maybe I need more coffee!) How do I get the scope of the query variable "x" to be available outside of the query? --------------------- let x="test";
console.log(x); //output="test"
wixData.query("portalMenu")
.contains("title", "stg" )
.limit(500)
.find()
.then( (results) => {
x=results.items[0].textValue;
console.log(x); //this displays correct value for "textValue" from the db based on query
});
console.log(x); //output="test" ---------------------- Any help would be most appreciated!!! Thanks
0
8
1k
jay.johnson
Sep 21, 2018
In Coding with Velo
Any ideas on how long fulfilling a new npm package request might take? I have requested that a package be included thru the Backend Package Request functionality, but I did not receive any indication on what length of time this might take to process. Do I get notified when the package is available or do I have to keep looking to see if it is included? Just trying to set my expectations as to when I should expect to have access to the modules I requested. This seems like a very cool feature. Can anyone share their experience with this?
0
1
85
jay.johnson
bottom of page