This is my code:
import wixData from ‘wix-data’;
$w.onReady( function () {
errorTextResult();
});
export function input1_keyPress(event) {
let SearchValue = $w(“#input1 ”).value;
$w(“#dataset1 ”).setFilter(wixData.filter().contains(‘location’, SearchValue))
}
function errorTextResult () {
$w(“#dataset1 ”).onReady( () => {
let count = $w(“#dataset1 ”).getTotalCount();
if (count > 0) {
$w(“#text4 ”).hide();
}
if (count === 0)
$w(“#text4 ”).show();
}
);
}
J.D
July 28, 2019, 10:34am
2
You’re missing a curly parentheses: { and that might cause an error.
It should be:
//....code..
if (count === 0) { // <<<< attention
$w("#text4").show();
}
//code...
J.D
July 28, 2019, 10:40am
3
Sorry, now I see that’s not the problem, because the closing parentheses belongs to the datase.onReady() function.
So I don’t know. Try console.log() to check if you get the correct total.
Hi @jonatandor35 !
Where shall I write “console.log()” within the code above?
J.D
July 28, 2019, 4:49pm
5
@callumsaffet after the line of " let count = $w(" #dataset1 ").getTotalCount(); ", put:
console.log(count);
and see what it logs to the console.
@jonatandor35 Thank you, but it still doesn’t work.
J.D
July 29, 2019, 8:31pm
7
@callumsaffet what does it log to the console?
@jonatandor35 Where do I go to check?
J.D
August 1, 2019, 10:33pm
9
@callumsaffet ,
In preview mode: open the console (it’s where your code is, but in preview mode it shows the console.)
On you live site (Chrome): click F12 then select the console tab.