Hello, I’m new to Wix Corvid. I’ve coded mostly through Wordpress, so I do not understand why the following code is not working. If anyone could walk me through this, it would be greatly appreciated. Thanks!
UPDATE: I have kept researching what could be the problem, and it seems like Wix doesn’t like comparing #primitivevalues to objects, so I tried to use the #String constructor on t1, but Wix didn’t like that either. What I decided to do next is to create another text object with the same text so that I could #compare the two objects, but now that doesn’t want to work either. What it does is it logs what’s in the comments, but it will still say that x !== t1 and change it to 722 Tractor ONLY (Electric). Here is my current code with comments:
Current Code:
export function iconButton1_click(event) {
$w(‘#text26’).show();
}
export function text18_mouseIn(event) {
var x = $w(‘#text18’); // 722 Tractor ONLY (Recoil)
var t1 = $w(‘#t1’); // 722 Tractor ONLY (Recoil)
console.log(x + " || " + t1); // [object Object] || [object Object]
console.log(x.type + " || " + t1.type); // $w.Text || $w.Text
console.log(x.text + " || " + t1.text); // 722 Tractor ONLY (Recoil) || 722 Tractor ONLY (Recoil)
if (!$w(“#text26”).hidden && x.text === t1.text) {
$w(‘#text18’).html = “722 Tractor ONLY (Recoil)”;
} else if (!$w(“#text26”).hidden && x.text !== t1.text) {
$w(‘#text18’).html = “722 Tractor ONLY (Electric)”;
}
}
Original Code:
export function text18_mouseOut(event) {
var x = $w(‘#text18’).text;
var t1 = ‘722 Tractor ONLY (Recoil)’;
console.log(x); //logs 722 Tractor ONLY (Recoil)
if (x === t1) {
$w(‘#text18’).html = “722 Tractor ONLY (Recoil)”;
} else if (x !== t1) {
console.log(t1); //also logs 722 Tractor ONLY (Recoil), but for some reason it is not registering that they are both the same text. Then the next line will change it to (Electric).
$w(‘#text18’).html = “722 Tractor ONLY (Electric)”;
}
}
If anyone needs more information, please let me know.