Hi,
I was able to specify the length of display text in a repeater, but when I paginate, it loses the restriction. How can I keep the ability to restrict the DefinitionText in the repeater when navigating through the pagination?
Page: https://www.idassoc.com/product-information-encyclopedia
Here is the code I used, can someone let me know what needs to be cleaned up or what I am missing? thx!
import wixData from “wix-data”;
import wixLocation from ‘wix-location’;
import {local} from ‘wix-storage’;
export function searchBox_keyPress(event, $w) {
console.log($w(‘#searchBox’).value);
filter($w(‘#searchBox’).value);
let debounceTimer
function update() {
if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
filter($w(‘#searchBox’).value);
}, 100);
}
}
function filter() {
$w(‘#dataset1’).setFilter(
wixData.filter()
.contains(‘article’, $w(‘#searchBox’).value)
.or(
wixData.filter()
.contains(‘acronym’, $w(‘#searchBox’).value)
)
).then(()=> {
if ($w(‘#dataset1’).getTotalCount()===0) {
$w(‘#noResText’).show();
} else {
$w(‘#noResText’).hide()
}
const shortTextLength = 60;
let fullText;
let shortText;
$w(“#repeater”).forEachItem(($w,item) => {
fullText = $w(‘#dataset1’).getCurrentItem().definition;
if (!fullText.length) {
$w(‘#DefinitionText’).collapse();
} else
if (fullText.length <= shortTextLength) {
$w(‘#DefinitionText’).text = fullText;
} **else** {
shortText = fullText.substr(0, shortTextLength) + "...";
$w('#DefinitionText').text = shortText;
}
}
)
}
)
}
$w.onReady( function () {
$w(“#dataset1”).onReady( function () {
const shortTextLength = 60;
let fullText;
let shortText;
$w(“#repeater”).forEachItem(($w,item) => {
fullText = $w(‘#dataset1’).getCurrentItem().definition;
if (!fullText.length) {
$w(‘#DefinitionText’).collapse();
} else
if (fullText.length <= shortTextLength) {
$w(‘#DefinitionText’).text = fullText;
} **else** {
shortText = fullText.substr(0, shortTextLength) + "...";
$w('#DefinitionText').text = shortText;
}
}
)
}
)
}
)