Using column as onClick

Hi, would like to use a column on my site as a button that links to another page on my site. Since I understood that function has to be onReady as well as onClick and import to, I’m quite confused and would love some help using JS code to manage this. Thanks

Hey Omer,

If I understand correctly, you want it so clicking on a Column will navigate to a different page on site? If so, just do the following:

  1. Make sure your Property Panel is open

  2. Make sure the component is selected

  3. Add an onClick function
    This steps are explained in this video tutorial if you’re not sure about any of them.
    Now as for what code to write, you’ll want to use the “to()” method of the wix-location module . If the onClick handler is named “button_click_handler” and the page you want to navigate is called “nameOfYourPage”, it will look something like this:

import wixLocation from 'wix-location'; 

function button_click_handler() {
  wixLocation.to("/nameOfYourPage");
}

Let me know how it went,

J.

Hi, thanks.

import wixLocation from ‘wix-location’;

function HAIRPRODUCT_click_handler() {
wixLocation.to(“/Shop”);
}

Tried changing with/without handler. The prob. is that onClick is defined as export function and doesn’t work without the export

Hi,
did you find a solution because i’ve got the same problem?