Potential Bug

Not so much a question, just an observation that may indicate a bug in the system.
.
My website has a number of hidden text messages that are made visible to provide help information. The messages are preset, but can be altered with new figures when required, in which case the text boxes are read back, modified and updated.
At some point in the last month this stopped working for a couple of messages on one page, and every attempt to read the boxes with <msg = $w('#testTextBox).text > crashed out with:

An error occurred in one of datasetReady callbacks TypeError: Illegal invocation
at P (eval at evaluateBundle (evaluateBundle.js:188), :3:13756)
at g (eval at evaluateBundle (evaluateBundle.js:188), :3:15392)
at Object.get text [as text] (eval at evaluateBundle (evaluateBundle.js:188), :3:15755)
at Object.keys.reduce.c.value.c.get.d.get [as text] (eval at evaluateBundle (evaluateBundle.js:188), :3:41469)

The only thing different about the failing messages was that they both contained a semicolon embedded in the text, and replacing them with hyphens fixed the problem. The text boxes were being read inside a dataset onReady, but moving that to outside the onReady made no difference.

I hope this is of use,
Kevin

The issue that you are having is not a known issue, and might be a result of your own code.

First, you are missing the closing tick mark for the element ID:

You have:

msg = $w('#testTextBox).text 

It should be:

msg = $w('#testTextBox').text 

Share whatever other code you feel is relevant here in a code block so you can get assistance.

Thanks for the reply Yisrael, and my apologies for the lack of detail. The missing tick mark that you picked up was the result of too much time at the computer.
To fill things out, one of the problem text boxes contained the following text:

This is based on an average of all domestic travel; the formulas used are: 
CO2e emitted = 



* #kg per domestic flight 

* #kg per inter-city bus trip 

* #kg per inter-island ferry trip 

The # symbols are replaced by figures retrieved from a table. According to the java console the line of code that fails is:
$w ( ‘#localTravelMsgTxt’ ). text = formatMsgTxt ( $w ( ‘#localTravelMsgTxt’ ). text , [ “Domestic flights” , “Inter-city bus” , “Inter-island ferry” ]);

The function formatMsgTxt is a held in ‘public/CalcUtils.js’ and is:

export function formatMsgTxt ( msgIn , names ) {
let msgOut = msgIn ;
names . forEach ( function ( name ) {
msgOut = msgOut . replace ( “#” , xFactor ( name ));
})
return msgOut ;

and function xFactor (also in public) looks up a table:

export function xFactor ( name ) {
let factor = 0 ;
let idx = globalVars . multiName . indexOf ( name );
if ( idx >= 0 ) {
factor = globalVars . multiNo [ idx ];
} else {
console . log ( "xFactor: no matching item in ‘Multipliers’ for " + name );
}
return factor ;

This code has not changed in 3 years, and is called successfully in 35 places across 10 pages, but it suddenly starting failing with 2 of the 3 messages on this particular page. The only thing different about the messages was that they both included a semicolon (after the word ‘travel’ in the example above). Replacing it with a hyphen fixed the problem in both cases.
After discovering this I added the $w(‘#testTextBox’) mentioned earlier to a different page, put in the words “A quick; brown fox #” and tried to read that from inside the onReady using msg = $w(’ #testTextBox ').text as mentioned. That also failed until I replaced the semicolon.

Having got rid of the semicolons I no longer have a problem, however I am concerned that what should be standard text appears to be acting as some sort of control character. I hope it can be resolved.

Cheers, Kevin

It’s not clear to me what’s happening. What text element are you using? How are you initially populating these fields?

A Text element has .text and .html properties. A TextBox element has a . value property.

Assuming you are using a Text element… You are retrieving text that you claim has a bulleted list, but you are retrieving it using the .text property which does not return Rich Text.

I set up a test and I can retrieve .text , and I get everything, including the semicolon , except for the bullets. If I retrieve .html , then I get everything, including a bunch of HTML for the bullets, etc.

Sorry, but I’m confused.

I also just noticed that in your original post, you are using datasets. Is it correct that the text elements are connected to fields in the dataset? Do you have code that uses the datasets?

Hi Yisrael,
My fault for using the wrong terminology - where I refer to text boxes please read text elements. They contain preset messages but where they include numbers I substitute # symbols then replace them with up-to-date figures at runtime. The numbers are read from a dataset into a table immediately after onReady, then are accessed from there - there is no direct link between the dataset and messages.

To put this all in context please look at the site:
www.carbonneutraltrust/household-calculator
That will take you to a carbon calculator - click on ‘Enter without login’. On the next page are two required fields; enter 1 for number of people and 1000 for the postcode, then click ‘Next’ to take you to the Energy page. Mousing over each of the blue information symbols will bring up one of the messages with the numbers included. Feel free to explore the other pages - the original error occurred in the Travel page, two pages further on…
I have added a test page called ‘household-test’ which you can reach by changing the URL. It is blank except for two text elements: #testText1 that does not include a semicolon, and #testText2 that does. The total code is:

$w.onReady(function () {
    let msg1 = $w('#testText1').text;
    console.log(msg1);

    let msg2 = $w('#testText2').text;
    console.log(msg2);
});

When I access this page this is what I get in the Java console:


Loading the code for the Household Test page. To debug this code, open cua7d.js in Developer Tools.
workerLogger.js:103 I’m a paragraph. Click here to add your own text and edit me. It’s easy. <<< Output from the first console,log
workerLogger.js:103 TypeError: Illegal invocation
at P (eval at evaluateBundle (evaluateBundle.js:188), :3:15247)
at g (eval at evaluateBundle (evaluateBundle.js:188), :3:16883)
at Object.get text [as text] (eval at evaluateBundle (evaluateBundle.js:188), :3:17246)
at Object.keys.reduce.c.value.c.get.d.get [as text] (eval at evaluateBundle (evaluateBundle.js:188), :3:45215)
at cua7d.js:8 <<< the 'let msg2 = ’ line
at wixSelector.ts:290
at tslib.es6.js:102
at Object.next (tslib.es6.js:83)
at tslib.es6.js:76
at new Promise ()


There were a couple of comments not shown in the code above, so the line numbering is a bit out.
I hope you can make something of all this Yisrael - especially if you can’t recreate it on your system. A good head-scratcher!

Kevin

I need the full URL in order to inspect.

www.carbonneutraltrust.co.nz/household-calculator

Link is broken. Site doesn’t load.

Apologies, the correct URL is:
www.carbonneutraltrust.org.nz/household-calculator

I have no clue what I need to do. Please provide the appropriate credentials, test data, and procedure to follow. Where to I see the problem? What works? What doesn’t?

Also, please understand that we are unable to debug or rewrite complex code and page configurations. If you feel that there is a bug in Velo/Wix, then you should try to create a minimum scenario that demonstrates the problem.

I have set up a screen which doesn’t require credentials to demonstrate the problem. Go to
www.carbonneutraltrust.org.nz /household-test

As detailed in the earlier post it contains just two text elements, "testText1 without a semicolon and #testText2 with one - they will be visible on screen. The entire page code is shown below. Run up a Java console, you will see that the code has crashed trying to read the text from #testText2 - you should see a trace similar to the one I included in the message of 11h ago.

The original fault was making the website unusable, but with the removal of the semicolons that has now been fixed. However the proof of the problem is demonstrated in this test page.

Kevin

// API Reference: https://www.wix.com/velo/reference/api-overview/introduction
// “Hello, World!” Example: https://learn-code.wix.com/en/article/1-hello-world

$w.onReady(function () {
    let msg1 = $w('#testText1').text;
    console.log(msg1);

    let msg2 = $w('#testText2').text;
    console.log(msg2);
});

This is bizzarrre (with 2 z’s and 3 r’s). Thank you for this test page - I see the console error.

I set up the same exact test and don’t see the problem, but on your site I do.

I am sending this on to QA for evaluation. There’s something fishy going on.

Hi @yisrael-wix ,

I was looking for similar issue and found this thread. I hit similar error recently. Go to my website below and open your browser console to check the error.

Error:
An error occurred in one of datasetReady callbacks TypeError: Illegal invocation
Code: (error disappear after I remove this line)
$w("#genJobText").html = job.jobDescHtml;
Content of job.jobDescHtml:
<div class="font_8" style="line-height:1.6em;padding-bottom: 50px;text-align: justify;"><p>JOB DESCRIPTION :</p><ul><li>Participate in deployment of system including user requirement scoping, design, coding, testing and implementation.</li><li>Ensure the successful delivery of the various products and solution with estimated time frames</li><li>Provide technical advice and recommendation for software solution and practices</li><li>Evaluate and adopt new technologies for company or team efficiency improvement</li><li>Maintain and support existing system.</li></ul><p><br></p><p>JOB REQUIREMENT :</p><ul><li>Min Yrs of Experience At least two (2) years of working experience in the related field is required for this position.</li><li>Education Level - At least Diploma/ Advanced/ Higher/ Graduate Diploma;Bachelor’s</li><li>Degree/ Post Graduate Diploma/ Professional Degree; Professional Certificate</li><li>Field of Studies - Computer Science/ Information Technology;Engineering (Computer/Telecommunication)</li><li>Required Skills - HTML, CSS (Boostrap), Javascript (Angular/ Vue.js/ React.js), PHP(Laravel), mySQL</li><li>Required language(s): English, Bahasa Malaysia</li></ul></div>

It appears that you are using HTML that is not supported, and this may be the cause of the error. See Formatting Text for the full list of HTML supported by the Text Element.

If you still are encountering this issue after cleaning up the HTML, bugs and system issues should be reported to Wix Customer Care .

@yisrael-wix Thanks. Works fine after the HTML clean-up.

I wish the error is descriptive for self debugging. The current error message is irrelevant & unhelpful. Thank you.