The code below works, kind of. Sometimes I have to refresh the page for it to work and I’m not sure why. Sometimes I have to refresh a couple times. To get to the page people click on a link with a query like so https://www.mytutorialcenter.com/training-progress?search=littletonma.myseniorcenter.net . I marked the 3 parts that I’m having issues with below. I thought maybe I needed
$w.onReady( function () {
$w( ‘#centers’ ).onReady(() => {
$w( ‘#progress’ ).onReady(() => {
$w( ‘#callLogs’ ).onReady(() => {
$w( ‘#notes’ ).onReady(() => {
let query = wixLocation.query.search;
console.log(query);
wixData.query( 'Centers' ).contains( 'subdomain' , query)
.or(wixData.query( 'Centers' ).contains( 'title' , query))
.or(wixData.query( 'Centers' ).contains( 'center_address' , query))
.limit( 10 )
.find()
.then(res => {
if (res.items.length === 1 ) {
const MyCID = res.items[ 0 ]._id
local.setItem( “CID” , MyCID);
$w( ‘#label’ ).text = MyCID
} else {
local.setItem( “CID” , ‘0000’ );
$w( ‘#label’ ).text = ‘Click Expand For the Center of Your Choice’
}
});
wixData.query( 'Centers' ).contains( 'subdomain' , query)
.limit( 10 )
.find()
.then(res => {
$w( '#centersRepeater' ).data = res.items;
$w( '#centersRepeater' ).show();
$w( '#centersRepeater' ).expand();
$w( "#searchBar" ).value = query
if ($w( ‘#label’ ).text === ‘Click Expand For the Center of Your Choice’ ) {} else {
const MyCID = $w( ‘#label’ ).text
wixData.query( ‘training_progrss’ )
.contains( ‘center_id’ , MyCID)
.limit( 100 )
.find()
.then(res2 => {
//these are the parts that sometimes don;t show unless I refresh the page
if (res2.items.length > 0 ) {
$w( ‘#trainingRepeater’ ).data = res2.items;
$w( ‘#trainingRepeater’ ).show();
$w( ‘#TrainingNotes’ ).show();
$w( ‘#trainingRepeater’ ).expand();
$w( ‘#TrainingNotes’ ).expand();
}
});
wixData.query( 'call_logs' )
.contains( 'center_id' , MyCID)
.limit( 100 )
.find()
.then(res3 => {
//these are the parts that sometimes don;t show unless I refresh the page
if (res3.items.length > 0 ) {
$w( ‘#callRepeater’ ).data = res3.items;
$w( ‘#callRepeater’ ).show();
$w( ‘#CallNotes’ ).show();
$w( ‘#callRepeater’ ).expand();
$w( ‘#CallNotes’ ).expand();
}
});
wixData.query( 'notes' )
.contains( 'centers_id' , MyCID)
.limit( 100 )
.find()
.then(res4 => {
//these are the parts that sometimes don;t show unless I refresh the page
if (res4.items.length > 0 ) {
$w( ‘#noteRepeater’ ).data = res4.items;
$w( ‘#noteRepeater’ ).show();
$w( ‘#gNotes’ ).show();
$w( ‘#noteRepeater’ ).expand();
$w( ‘#gNotes’ ).expand();
}
});
}
});
});
});
});
});
});