Hoping someone has some idea about this question. I display content based on a wixData.query. The results display correctly but only for the first 20 records in a database of 40 records in total. I've tried adding the limit() but doesn't fix the problem. Any one has a suggestion of what is wrong with the code or missing something? Any help so appreciated, here's the code I'm using to display the results:
$w.onReady(function () {
$w("#dataset16").onReady(()=> {
wixData.query('SiteMap')
.eq("title", "ajax")
.find()
.then( (results) => {
if(results.items.length > 0) {
$w('#ajax').html = results.items[0].city;
$w('#ajax1').html = results.items[0].services1;
$w('#ajax2').html = results.items[0].services2;
$w('#ajax3').html = results.items[0].services3;
}
})
wixData.query('SiteMap')
.eq("title", "aurora")
.find()
.then( (results) => {
if(results.items.length > 0) {
$w('#aurora').html = results.items[0].city;
$w('#aurora1').html = results.items[0].services1;
$w('#aurora2').html = results.items[0].services2;
$w('#aurora3').html = results.items[0].services3;
}
})
wixData.query('SiteMap')
.eq("title", "barrie")
.find()
.then( (results) => {
if(results.items.length > 0) {
$w('#barrie').html = results.items[0].city;
$w('#barrie1').html = results.items[0].services1;
$w('#barrie2').html = results.items[0].services2;
$w('#barrie3').html = results.items[0].services3;
}
})
wixData.query('SiteMap')
.eq("title", "brantford")
.find()
.then( (results) => {
if(results.items.length > 0) {
$w('#brantford').html = results.items[0].city;
$w('#brantford1').html = results.items[0].services1;
$w('#brantford2').html = results.items[0].services2;
$w('#brantford3').html = results.items[0].services3;
}
})
wixData.query('SiteMap')
.eq("title", "burlington")
.find()
.then( (results) => {
if(results.items.length > 0) {
$w('#burlington').html = results.items[0].city;
$w('#burlington1').html = results.items[0].services1;
$w('#burlington2').html = results.items[0].services2;
$w('#burlington3').html = results.items[0].services3;
}
})
wixData.query('SiteMap')
.eq("title", "guelph")
.find()
.then( (results) => {
if(results.items.length > 0) {
$w('#guelph').html = results.items[0].city;
$w('#guelph1').html = results.items[0].services1;
$w('#guelph2').html = results.items[0].services2;
$w('#guelph3').html = results.items[0].services3;
}
})
wixData.query('SiteMap')
.eq("title", "kitchener")
.find()
.then( (results) => {
if(results.items.length > 0) {
$w('#kitchener').html = results.items[0].city;
$w('#kitchener1').html = results.items[0].services1;
$w('#kitchener2').html = results.items[0].services2;
$w('#kitchener3').html = results.items[0].services3;
}
})
wixData.query('SiteMap')
.eq("title", "newmarket")
.find()
.then( (results) => {
if(results.items.length > 0) {
$w('#newmarket').html = results.items[0].city;
$w('#newmarket1').html = results.items[0].services1;
$w('#newmarket2').html = results.items[0].services2;
$w('#newmarket3').html = results.items[0].services3;
}
})
wixData.query('SiteMap')
.eq("title", "whitby")
.find()
.then( (results) => {
if(results.items.length > 0) {
$w('#whitby').html = results.items[0].city;
$w('#whitby1').html = results.items[0].services1;
$w('#whitby2').html = results.items[0].services2;
$w('#whitby3').html = results.items[0].services3;
}
})
wixData.query('SiteMap')
.eq("title", "windsor")
.find()
.then( (results) => {
if(results.items.length > 0) {
$w('#windsor').html = results.items[0].city;
$w('#windsor1').html = results.items[0].services1;
$w('#windsor2').html = results.items[0].services2;
$w('#windsor3').html = results.items[0].services3;
}
})
wixData.query('SiteMap')
.eq("title", "brampton")
.find()
.then( (results) => {
if(results.items.length > 0) {
$w('#brampton').html = results.items[0].city;
$w('#brampton1').html = results.items[0].services1;
$w('#brampton2').html = results.items[0].services2;
$w('#brampton3').html = results.items[0].services3;
}
})
wixData.query('SiteMap')
.eq("title", "cambridge")
.find()
.then( (results) => {
if(results.items.length > 0) {
$w('#cambridge').html = results.items[0].city;
$w('#cambridge1').html = results.items[0].services1;
$w('#cambridge2').html = results.items[0].services2;
$w('#cambridge3').html = results.items[0].services3;
}
})
wixData.query('SiteMap')
.eq("title", "collingwood")
.find()
.then( (results) => {
if(results.items.length > 0) {
$w('#collingwood').html = results.items[0].city;
$w('#collingwood1').html = results.items[0].services1;
$w('#collingwood2').html = results.items[0].services2;
$w('#collingwood3').html = results.items[0].services3;
}
})
wixData.query('SiteMap')
.eq("title", "cornwall")
.find()
.then( (results) => {
if(results.items.length > 0) {
$w('#cornwall').html = results.items[0].city;
$w('#cornwall1').html = results.items[0].services1;
$w('#cornwall2').html = results.items[0].services2;
$w('#cornwall3').html = results.items[0].services3;
}
})
wixData.query('SiteMap')
.eq("title", "etobicoke")
.find()
.then( (results) => {
if(results.items.length > 0) {
$w('#etobicoke').html = results.items[0].city;
$w('#etobicoke1').html = results.items[0].services1;
$w('#etobicoke2').html = results.items[0].services2;
$w('#etobicoke3').html = results.items[0].services3;
}
})
wixData.query('SiteMap')
.eq("title", "hamilton")
.find()
.then( (results) => {
if(results.items.length > 0) {
$w('#hamilton').html = results.items[0].city;
$w('#hamilton1').html = results.items[0].services1;
$w('#hamilton2').html = results.items[0].services2;
$w('#hamilton3').html = results.items[0].services3;
}
})
wixData.query('SiteMap')
.eq("title", "kingston")
.find()
.then( (results) => {
if(results.items.length > 0) {
$w('#kingston').html = results.items[0].city;
$w('#kingston1').html = results.items[0].services1;
$w('#kingston2').html = results.items[0].services2;
$w('#kingston3').html = results.items[0].services3;
}
})
wixData.query('SiteMap')
.eq("title", "london")
.find()
.then( (results) => {
if(results.items.length > 0) {
$w('#london').html = results.items[0].city;
$w('#london1').html = results.items[0].services1;
$w('#london2').html = results.items[0].services2;
$w('#london3').html = results.items[0].services3;
}
})
wixData.query('SiteMap')
.eq("title", "milton")
.find()
.then( (results) => {
if(results.items.length > 0) {
$w('#milton').html = results.items[0].city;
$w('#milton1').html = results.items[0].services1;
$w('#milton2').html = results.items[0].services2;
$w('#milton3').html = results.items[0].services3;
}
})
wixData.query('SiteMap')
.eq("title", "mississauga")
.find()
.then( (results) => {
if(results.items.length > 0) {
$w('#mississauga').html = results.items[0].city;
$w('#mississauga1').html = results.items[0].services1;
$w('#mississauga2').html = results.items[0].services2;
$w('#mississauga3').html = results.items[0].services3;
}
})
wixData.query('SiteMap')
.eq("title", "niagara")
.find()
.then( (results) => {
if(results.items.length > 0) {
$w('#niagara').html = results.items[0].city;
$w('#niagara1').html = results.items[0].services1;
$w('#niagara2').html = results.items[0].services2;
$w('#niagara3').html = results.items[0].services3;
}
})
wixData.query('SiteMap')
.eq("title", "north bay")
.find()
.then( (results) => {
if(results.items.length > 0) {
$w('#northbay').html = results.items[0].city;
$w('#northbay1').html = results.items[0].services1;
$w('#northbay2').html = results.items[0].services2;
$w('#northbay3').html = results.items[0].services3;
}
})
wixData.query('SiteMap')
.eq("title", "north york")
.find()
.then( (results) => {
if(results.items.length > 0) {
$w('#northyork').html = results.items[0].city;
$w('#northyork1').html = results.items[0].services1;
$w('#northyork2').html = results.items[0].services2;
$w('#northyork3').html = results.items[0].services3;
}
})
wixData.query('SiteMap')
.eq("title", "oakville")
.find()
.then( (results) => {
if(results.items.length > 0) {
$w('#oakville').html = results.items[0].city;
$w('#oakville1').html = results.items[0].services1;
$w('#oakville2').html = results.items[0].services2;
$w('#oakville3').html = results.items[0].services3;
}
})
wixData.query('SiteMap')
.eq("title", "orangeville")
.find()
.then( (results) => {
if(results.items.length > 0) {
$w('#orangeville').html = results.items[0].city;
$w('#orangeville1').html = results.items[0].services1;
$w('#orangeville2').html = results.items[0].services2;
$w('#orangeville3').html = results.items[0].services3;
}
})
wixData.query('SiteMap')
.eq("title", "orillia")
.find()
.then( (results) => {
if(results.items.length > 0) {
$w('#orillia').html = results.items[0].city;
$w('#orillia1').html = results.items[0].services1;
$w('#orillia2').html = results.items[0].services2;
$w('#orillia3').html = results.items[0].services3;
}
})
wixData.query('SiteMap')
.eq("title", "oshawa")
.find()
.then( (results) => {
if(results.items.length > 0) {
$w('#oshawa').html = results.items[0].city;
$w('#oshawa1').html = results.items[0].services1;
$w('#oshawa2').html = results.items[0].services2;
$w('#oshawa3').html = results.items[0].services3;
}
})
wixData.query('SiteMap')
.eq("title", "ottawa")
.find()
.then( (results) => {
if(results.items.length > 0) {
$w('#ottawa').html = results.items[0].city;
$w('#ottawa1').html = results.items[0].services1;
$w('#ottawa2').html = results.items[0].services2;
$w('#ottawa3').html = results.items[0].services3;
}
})
wixData.query('SiteMap')
.eq("title", "peterborough")
.find()
.then( (results) => {
if(results.items.length > 0) {
$w('#peterborough').html = results.items[0].city;
$w('#peterborough1').html = results.items[0].services1;
$w('#peterborough2').html = results.items[0].services2;
$w('#peterborough3').html = results.items[0].services3;
}
})
wixData.query('SiteMap')
.eq("title", "pickering")
.find()
.then( (results) => {
if(results.items.length > 0) {
$w('#pickering').html = results.items[0].city;
$w('#pickering1').html = results.items[0].services1;
$w('#pickering2').html = results.items[0].services2;
$w('#pickering3').html = results.items[0].services3;
}
})
wixData.query('SiteMap')
.eq("title", "richmond hill")
.find()
.then( (results) => {
if(results.items.length > 0) {
$w('#richmondhill').html = results.items[0].city;
$w('#richmondhill1').html = results.items[0].services1;
$w('#richmondhill2').html = results.items[0].services2;
$w('#richmondhill3').html = results.items[0].services3;
}
})
wixData.query('SiteMap')
.eq("title", "sarnia")
.find()
.then( (results) => {
if(results.items.length > 0) {
$w('#sarnia').html = results.items[0].city;
$w('#sarnia1').html = results.items[0].services1;
$w('#sarnia2').html = results.items[0].services2;
$w('#sarnia3').html = results.items[0].services3;
}
})
wixData.query('SiteMap')
.eq("title", "sault ste marie")
.find()
.then( (results) => {
if(results.items.length > 0) {
$w('#saultstemarie').html = results.items[0].city;
$w('#saultstemarie1').html = results.items[0].services1;
$w('#saultstemarie2').html = results.items[0].services2;
$w('#saultstemarie3').html = results.items[0].services3;
}
})
wixData.query('SiteMap')
.eq("title", "st catharines")
.find()
.then( (results) => {
if(results.items.length > 0) {
$w('#stcatharines').html = results.items[0].city;
$w('#stcatharines1').html = results.items[0].services1;
$w('#stcatharines2').html = results.items[0].services2;
$w('#stcatharines3').html = results.items[0].services3;
}
})
wixData.query('SiteMap')
.eq("title", "sudbury")
.find()
.then( (results) => {
if(results.items.length > 0) {
$w('#sudbury').html = results.items[0].city;
$w('#sudbury1').html = results.items[0].services1;
$w('#sudbury2').html = results.items[0].services2;
$w('#sudbury3').html = results.items[0].services3;
}
})
wixData.query('SiteMap')
.eq("title", "thunder bay")
.find()
.then( (results) => {
if(results.items.length > 0) {
$w('#thunderbay').html = results.items[0].city;
$w('#thunderbay1').html = results.items[0].services1;
$w('#thunderbay2').html = results.items[0].services2;
$w('#thunderbay3').html = results.items[0].services3;
}
})
wixData.query('SiteMap')
.eq("title", "toronto")
.find()
.then( (results) => {
if(results.items.length > 0) {
$w('#toronto').html = results.items[0].city;
$w('#toronto1').html = results.items[0].services1;
$w('#toronto2').html = results.items[0].services2;
$w('#toronto3').html = results.items[0].services3;
}
})
wixData.query('SiteMap')
.eq("title", "vaughan")
.find()
.then( (results) => {
if(results.items.length > 0) {
$w('#vaughan').html = results.items[0].city;
$w('#vaughan1').html = results.items[0].services1;
$w('#vaughan2').html = results.items[0].services2;
$w('#vaughan3').html = results.items[0].services3;
}
})
wixData.query('SiteMap')
.eq("title", "waterloo")
.find()
.then( (results) => {
if(results.items.length > 0) {
$w('#waterloo').html = results.items[0].city;
$w('#waterloo1').html = results.items[0].services1;
$w('#waterloo2').html = results.items[0].services2;
$w('#waterloo3').html = results.items[0].services3;
}
})
wixData.query('SiteMap')
.eq("title", "welland")
.find()
.then( (results) => {
if(results.items.length > 0) {
$w('#welland').html = results.items[0].city;
$w('#welland1').html = results.items[0].services1;
$w('#welland2').html = results.items[0].services2;
$w('#welland3').html = results.items[0].services3;
}
})
})
})
The code works perfectly until query 20 "north york"
But the second 20 querys return only the last item in collection. If i remove the first 20 queries from the code the second 20 display correctly. Why won't this code work display correctly for ALL 40 items in collection?
Any suggestions anybody?
Thank you greatly in advance
i've now updated this line for each query
if(results.items.length > 0) {
to this
if(results.items[0].title === 'barrie') {
AND IT STILL ONLY DISPLAYS THE FIRST 20 RESULTS WHAT AM I DOING WRONG... SOMETHING SO SIMPLE TAKING DAYS.... IS IT A BUG? PLS ANYBODY ANY SUGGESTION I CAN TRY?
_______________
Update:
I've even tried .gt
$w.onReady(function () {
$w("#dataset16").onReady(()=> {
wixData.get("SiteMap", 'b7780cf1-f4a2-4b80-9dd6-8c4374844c15')
.then( (results) => {
let item = results;
$w('#ajax').html = results.city;
$w('#ajax1').html = results.services1;
$w('#ajax2').html = results.services2;
$w('#ajax3').html = results.services3;
})
I've even tried putting code , text box elements in alphabetical order with the collection
NOTHING WORKS