Wix: Mobile view Lightbox reveals a hint of obscurity

On my mobile website, I needed to hide a lightbox connected to a box and have the box redirect to a different page when clicked.

I implemented the code below to hide the lightbox.

import wixLocation from 'wix-location'; 
import wixWindow from 'wix-window';

$w.onReady(function () {
    if(wixWindow.formFactor === "Mobile"){
        $w('#lightbox1').hide();
    }
});

Next, I used this code to achieve the redirection upon clicking the box.

import wixLocation from 'wix-location'; 
import wixWindow from 'wix-window';

$w.onReady(function () {
    if(wixWindow.formFactor === "Mobile"){
        $w('#box3').onClick(function(){
            wixLocation.to('/flagevt-mob');
        });
    }
    
});

Although the redirection works when clicking on box3 in mobile view and the lightbox is hidden, there is still some shading that requires an additional click to remove. It's like popping a bubble.

If anyone could assist with why this issue is happening, it would be greatly appreciated.

For reference, here is a link to the site. Feel free to check it out on both desktop and mobile views. You can identify the box associated with box3 by locating the text "FLAGSHIP EVENTS" on the page.

Answer №1

If you're looking to achieve the functionality of displaying a lightbox on desktop and redirecting to a page on mobile when a button is clicked, you can follow this code snippet:

import wixLocation from 'wix-location';
import wixWindow from 'wix-window';

$w.onReady(function () {
    $w('#box3').onClick(function(){
       if(wixWindow.formFactor === "Mobile"){
           wixLocation.to('/flagevt-mob');
       } else {
           wixWindow.openLightbox("LightboxName");
       }
    });
});

It's recommended not to link the button to your lightbox using this method.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Encountering a "404 method not found" error in the developer console when handling meteor collections

Having an issue while trying to insert a document into my meteor collection using an autoform generated from my Mongo schema. Upon clicking the submit button, I am encountering a "method not found [404]" error in the developer console. I suspect the proble ...

Navigating Through Different Environments in Your React Application

Currently, I am tackling a small project where I am utilizing React for the frontend and Java for the backend. The project involves two distinct environments. My main struggle revolves around effectively managing multiple environments. To set the API URL, ...

display the presently active dot in the slick slider

I am currently facing an issue with my slider. It currently shows the total slide count as the number of dots, but I also want to display the current active dot number instead of the active slide number. Here is the relevant section of my code: var $status ...

Anchor tag in AngularJS not responding to ng-disabled directive

I have been successfully using ng-disabled for input and buttons, but I have run into an issue with anchor tags. How can I make it work for anchor tags as well? HTML code <a ng-disabled="addInviteesDisabled()">Add</a> JS code $scope.addIn ...

Exploring the Dynamics of AngularJS: Leveraging ng-repeat and ng-show

Recently, I came across this code snippet: <div class="map" ng-controller="DealerMarkerListCtrl"> <a ng-click="showdetails=!showdetails" href="#/dealer/{{marker.id}}" class="marker" style="left:{{marker.left}}px;top:{{marker.top}}px" ng-rep ...

Tips for implementing autocomplete in a textbox on an ASP.NET website with jQuery

Make sure to include a control named ProductType of type textbox in your .aspx page. [WebMethod(EnableSession = true)] public static List<string> GetAutoCompleteDataProduct(string ProductType) { // string pid = ""; ProductMas ...

Issue with formatting data correctly in JSON file while using Express.js

I am facing an issue with loading data from a JSON file into an array in the correct format: var jobs = [ { ID: 'grt34hggdggf', Employer: 'A1', Title: 'tobi1', Location: 'Los Angeles, CA', Department: 'depart ...

Removing the switcher outline in Bootstrap Switch: a step-by-step guide

I have implemented the bootstrap-switch - v3.3.1, however, I want to remove the default blue outline that appears around the switcher when toggling it on or off. Despite setting style="outline: 0 none; for the input, the outline remains visible. Below is ...

Guide: Highlighting a selected link in Navigation without redirecting the page can be achieved in AngularJS by utilizing

I have a list of links that I want to be able to highlight when clicked without redirecting to the page. Below is the code snippet: HTML <ul class="nav nav-list"> <li ng-repeat="navLink in navLinks" ng-class="navClass('{{navLink.Title ...

Executing jQuery after the body has finished loading

I'm trying to execute a JavaScript function once the body has finished loading. My framework loads the header and footer from static files, while the body content is dynamic. I read online that I should place the $(elem).load(function()) at the end of ...

What is the best way to switch back and forth between two div elements?

I've been attempting to switch between displaying div .cam1 and div .cam2, however, I can't seem to get it to work. Here's the code snippet in question: HTML: <div class="cam1"></div> <div class="cam2"></div> CS ...

Storing numerous JSON records into an array by parsing them from a file

As a beginner in JS programming, I have a question that may seem trivial. Despite hours of searching online, I haven't been able to find a solution that works for me. I am dealing with multiple JSON feeds where each URL provides a multilayer JSON rec ...

Guide to Re-rendering a component inside the +layout.svelte

Can you provide guidance on how to update a component in +layout.svelte whenever the userType changes? I would like to toggle between a login and logout state in my navbar, where the state is dependent on currentUserType. I have a store for currentUserTyp ...

What is the best way to apply and remove class from buttons in a React application?

There are a total of 20 buttons and I want to apply the class .active to the button that is clicked, while removing it from any previously active button. For example, if I click on button one, it should become active and if I then click on button two, bu ...

The Position of the WebGL Globe Within the Environment

I've been experimenting with the WebGL Globe, and I have successfully made it rotate. However, I'm struggling to figure out how to adjust its position so that it's not centered in the scene. After making changes to the code found at https:/ ...

The file reading code in my Node.js application suddenly stopped working

I have a basic web application that I am currently developing using Node.js and Express. This is a breakdown of my package structure: https://i.stack.imgur.com/D7hJx.png The entries in my questions.json file are outlined below: [ { "question": "Wh ...

Execute JavaScript/AJAX solely upon the selection of a button

Currently, my script is being executed immediately after the page loads and then again after a button click. Is there any way to modify it so that the script waits until I click the button before running? As far as I understand, this code runs asynchronous ...

Basic authentication for cross-domain ajax requests

I'm currently working on a cross-domain ajax request in order to retrieve some important data. The REST service I am connecting to requires Basic authentication, which is configured through IIS. $.ajax({ type: "GET", xhrFields ...

Effective ways to replace an image using JavaScript

I am currently working on implementing a show/hide function, but I am encountering an issue with swapping the image (bootstrap class). The show-hide function is functioning properly; however, I am struggling to determine which class is currently displayed. ...

Implementing src attribute to HTML5 audio tag utilizing angularjs

Currently, I am in the process of creating a music website and facing an issue where I need to pass the name of the file when the user clicks on the music cover image to the HTML5 audio tag. My approach involves playing songs using PHP, but it requires a p ...