Right here is the answer for you on this website.
https://givemeawhisky.wixsite.com/richtexttest
I have had to change your code used with the setFilter() function on page 2.
When you use query you can query the dataset and then show the results in the repeater or the table which is shown in page 1.
However, when you use filter you have to filter the dataset itself and you can’t then use the code to show the results in the repeater or table.
You simply have to connect the repeater or the table to the dataset and then use your filter code to filter the results shown in the repeater or table.
The purple table on each page is just showing you the contents of the dataset that I have used for this example, so if you search for ‘this’ you will get all six items returned as it is in all used fields. However, if you search for ‘plain’ or ‘bold’ you will only get returned either the four plain or the four bold items.
Page 1 is the example as it is with a repeater to display, the only extra thing added is your onKeypress event.
Page 1 Search:
import { local } from 'wix-storage';
import wixLocation from 'wix-location';
$w.onReady(function () {
});
export function searchButton_click() {
let word = $w("#searchBar").value; //Make sure to change the ID of your elements to match the code
local.setItem("searchWord", word); //This is your search variable
wixLocation.to(`/page1-results`); //Change this to the URL ending of your results page
}
export function searchBar_keyPress(event) {
if (event.key === "Enter") {
searchButton_click();
}
}
Page 1 Results:
import { local } from 'wix-storage';
import wixData from 'wix-data';
$w.onReady(function () {
var sameWord = local.getItem("searchWord");
$w("#searchBar").value = sameWord;
$w("#searchBar").placeholder = sameWord;
$w('#dataset1').onReady(function () {
search();
});
});
export function searchBar_keyPress(event) {
if (event.key === "Enter") {
searchButton_click();
}
}
export function searchButton_click() {
search();
}
function search() {
wixData.query('RichTextTest')
.contains('richTextField', $w("#searchBar").value)
.or(wixData.query('RichTextTest').contains('textField1', $w("#searchBar").value))
.find()
.then(res => {
$w('#repeater1').data = res.items;
});
}
Page 2 is the same tutorial with a repeater to display, however it has your used code for it instead of the example.
Page 2 Search:
import { local } from 'wix-storage';
import wixLocation from 'wix-location';
$w.onReady(function () {
});
export function searchButton_click() {
let word = $w("#searchBar").value; //Make sure to change the ID of your elements to match the code
local.setItem("searchWord", word); //This is your search variable
wixLocation.to(`/page2-results`); //Change this to the URL ending of your results page
}
export function searchBar_keyPress(event) {
if (event.key === "Enter") {
searchButton_click();
}
}
Page 2 Results:
import { local } from 'wix-storage';
import wixData from 'wix-data';
$w.onReady(function () {
var sameWord = local.getItem("searchWord");
$w("#searchBar").value = sameWord;
$w("#searchBar").placeholder = sameWord;
$w('#dataset1').onReady(function () {
searchButton_click();
});
});
export function searchBar_keyPress(event) {
if (event.key === "Enter") {
searchButton_click();
}
}
export function searchButton_click() {
$w("#dataset1").setFilter( wixData.filter()
.contains('richTextField', $w("#searchBar").value)
.or(
wixData.filter()
.contains('textField1', $w("#searchBar").value)
)
)
.then( () => {
console.log("Dataset is now filtered");
} )
.catch( (err) => {
console.log(err);
});
}
Page 3 is the same as page 2 with your code being used instead, however a table is now being used to display instead of a repeater.
Page 3 Search:
import { local } from 'wix-storage';
import wixLocation from 'wix-location';
$w.onReady(function () {
});
export function searchButton_click() {
let word = $w("#searchBar").value;
local.setItem("searchWord", word);
wixLocation.to(`/page3-results`);
}
export function searchBar_keyPress(event) {
if (event.key === "Enter") {
searchButton_click();
}
}
Page 3 Results:
import { local } from 'wix-storage';
import wixData from 'wix-data';
$w.onReady(function () {
var sameWord = local.getItem("searchWord");
$w("#searchBar").value = sameWord;
$w("#searchBar").placeholder = sameWord;
$w('#dataset1').onReady(function () {
searchButton_click();
});
});
export function searchBar_keyPress(event) {
if (event.key === "Enter") {
searchButton_click();
}
}
export function searchButton_click() {
$w("#dataset1").setFilter( wixData.filter()
.contains('richTextField', $w("#searchBar").value)
.or(
wixData.filter()
.contains('textField1', $w("#searchBar").value)
)
)
.then( () => {
console.log("Dataset is now filtered");
} )
.catch( (err) => {
console.log(err);
});
}