Description
When the page are loading the system shall automatically check if the member are currently renting a specific video and if that is the case the dark lamp image shall collapse and the bright lamp image shall expand but that doesn´t occur whatever I do. I have tried and tried with different alternatives but never succede with anything. The “expiryDate1” and “expiryDate2” fields etc. are empty if the member are not renting the videos and they are filled with a date if there is a renting time for the videos. Now you should understand my pretty simple plan.
So my main question is why none of this two pretty “easy” codes work as intended? The dark lamp image doesn´t collapse and the bright lamp doesn´t expand. Extremely frustrating because I can´t understand why it refuse. I have earlier tried with a repeater but that made it even more complicated so now I have connected everything separately.
Alternative 1:
wixData . get ( “Members” , wixUsers . currentUser . id )
return wixData . query ( “Rentingmembers” )
. eq ( ‘expiryDate1’ )
. find ()
. then (( results ) => {
let date = $w ( “#dataset5” ). getCurrentItem (). expiryDate1 ;
if ( results . length === 0 ) {
console . log ( “Not renting” );
} else {
$w ( “#date1” ). text = date . toLocaleDateString ()
$w ( “#image138” ). collapse ();
$w ( ‘#image139’ ). expand ();
console . log ( date )
}
});
});
Alternative 2:
wixData . **get** ( "Members" , wixUsers . currentUser . id )
$w ( "#dataset5" ). onReady (() => {
**let** date = $w ( "#dataset5" ). getCurrentItem (). expiryDate2 ;
**if** ( date . length === 0 ) {
console . log ( "Not renting" );
} **else** {
$w ( "#date2" ). text = date . toLocaleDateString ()
$w ( "#image151" ). collapse ();
$w ( '#image140' ). expand ();
console . log ( date );
}
});