switchTo

Callable

  • Opens the given product surface in the designer. Returns the product with the given surface (page) opened.

    example
    editor.getProduct()
        .then(function (product) {
            // Get the current surface index.
            const indexOfCurrentSurface = product.surfaces.lastIndexOf(product.currentSurface);
            if (indexOfCurrentSurface < 0)
                throw "Surface not found!";
    
            let indexOfNextSurface = indexOfCurrentSurface + 1;
            if (indexOfNextSurface > (product.surfaces.length - 1))
                indexOfNextSurface = 0;
    
            // Switch to the next surface.
            return product.switchTo(product.surfaces[indexOfNextSurface]);
        })
        .then(function(result) {
            console.log("Surface switched");
        })
        .catch(function (error) {
            console.error("Switching the surfaces failed with exception: ", error);
        });
    

    Parameters

    • surface: Surface

      A surface (page) to open.

    Returns Promise < Product >