Code stopped working on desktop/mobile

Hi, I have a code on one of the pages of my wedding website that was working on desktop but not on mobile. I’ve been trying to make changes to it to get the published mobile site to work but don’t have any luck. Also, it has now seemed to stop working for the published desktop site as well. It all works on the preview modes, both desktop and mobile.

Guests should be able to type in their full names and click the “Find My Invitation” button and have the box expand once entered, but the “find my invitation” button doesn’t work on desktop or mobile once published.

This is the code:

import wixLocation from ‘wix-location’ ;
import wixData from ‘wix-data’ ;
var number = 0 ;
var family = " " ;

$w . onReady ( function () {
$w ( “#box1” ). collapse ();
$w ( “#errortext” ). hide ();
$w ( “#submittext” ). hide ();
$w ( “#table1” ). hide ();

});

export function button10_click ( event ) { //find my invitation button
$w ( ‘#box1’ ). collapse ();
$w ( ‘#errortext’ ). hide ();
for ( var i = 1 ; i < 6 ; i ++) {
var q = i ;
var identifier = “#name” + q ;
$w ( identifier ). collapse ();
identifier = “#selectionTags” + q ;
$w ( identifier ). collapse ();
}
var name = $w ( ‘#nameinput’ ). value ;

$w ( '#nameinput' ). value  =  name 

wixData . query ( "responses" )  //responsesdatabase 
    . contains ( "name" ,  name ) 
    . find () 
    . then (( res ) => { 
        **if**  ( res . items . length  ==  1 ) { 
            $w ( "#errortext" ). text  =  "You or someone in your party has already submitted an RSVP. Thank you!" ; 
            $w ( "#errortext" ). show (); 
        }  **else**  { 
            wixData . query ( "GuestList" )  //check for firstname matches 
                . eq ( "fullName" ,  name ) 
                . find () 
                . then (( res ) => { 
                    **if**  ( res . items . length  >  0 ) { 
                        **let**  firstItem  =  res . items [ 0 ];  //First item in results 
                        $w ( '#box1' ). expand (); 
                        //$w("#submittext").hide(); 
                        number  =  firstItem . guestNumbers ; 
                        family  =  firstItem . family ;  //family name identifies party 
                        **if**  ( number  ==  1 ) {  //if only one guest 
                            $w ( '#text2' ). text  =  "We have reserved one seat in your honour." 
                            $w ( '#name1' ). expand (); 
                            $w ( '#name1' ). text  =  name ; 
                            $w ( '#selectionTags1' ). expand (); 
                        }  **else**  {  //if multiple guests 
                            $w ( '#text2' ). text  =  "We have reserved "  +  number  +  " seats in your honour." 
                            wixData . query ( "GuestList" )  //find # of people w family name 
                                . eq ( "family" ,  family ) 
                                . find () 
                                . then (( res ) => { 
                                    //$w("#submittext").hide(); 
                                    //fill in each name in rsvp section 
                                    **for**  ( **let**  i  =  0 ;  i  <  number ;  i ++) { 
                                        **var**  q  =  i  +  1 ; 
                                        **var**  identifier  =  "#selectionTags"  +  q ; 
                                        $w ( identifier ). expand (); 
                                        **var**  identifier  =  "#name"  +  q ; 
                                        $w ( identifier ). text  =  res . items [ i ]. fullName ; 
                                        $w ( identifier ). expand (); 
                                    } 
                                }); 
                        } 
                    }  **else**  { 
                        $w ( '#errortext' ). text  =  "Please try again, or contact the couple for help." ; 
                        $w ( '#errortext' ). show (); 
                    } 
                }); 
        } 
    }); 

}

export function button2_click ( event ) {
$w ( “#button2” ). disable ();
//$w(“#group1”).expand();
for ( var i = 0 ; i < number ; i ++) {
//add to database
var q = i + 1 ;
var identifier = “#name” + q ;
var name = $w ( identifier ). text ;
let tag = “#selectionTags” + q ;
if ( $w ( tag ). selectedIndices [ 0 ] == 0 ) { //accept
//add to database
let toInsert = {
“name” : name ,
“rsvp” : “Yes” ,
“hotel” : $w ( ‘#textBox1’ ). value ,
“song” : $w ( ‘#textBox2’ ). value
};
wixData . insert ( “responses” , toInsert )
. then (( results ) => {
$w ( “#submittext” ). show ();
})
. catch (( err ) => {
let errorMsg = err ;
});
} else if ( $w ( tag ). selectedIndices [ 0 ] == 1 ) { //decline
let toInsert = {
“name” : name ,
“rsvp” : “No”
};
wixData . insert ( “responses” , toInsert )
. then (( results ) => {
$w ( “#submittext” ). show ();
})
. catch (( err ) => {
let errorMsg = err ;
});
}
}
}

Published Mode:


Edit Mode:

If your code to search the collection for an invitation works in preview but not live, I would suggest checking the collection permissions.

Hi, thank you for your suggestion. I checked both datasets and no luck. Any other ideas?

Can you check and see if you are using sandbox data or live data?

Sandbox vs. Live data article

If that isnt’ it either and you link your site, I’ll take a look and see if I notice anything obvious tomorrow

I am using sandbox data and the page is linked to the specific dataset.

Perfect! Glad you found the issue, as a reminder you must sync to the live data to be able to see it on the published site. Refer to the link I sent previously if you need to know how to do this.

Ahh, unfortunately no, I wasn’t able to solve the issue :frowning: It was already set to sandbox data previously when it was working before. And when I went on to the site yesterday for some reason it just wasn’t working anymore.

I tried changing it to live data but that didn’t fix the issue either.