Adding navigation to application
Last updated
Was this helpful?
Last updated
Was this helpful?
UI Bakery supports both in-app and external navigation. In this article, we'll explore these options in more details.
There are a number of ways to configure navigation inside the application:
You can configure navigation both to an internal application page as well as to an external website.
You can configure navigation using the Menu and Horizontal menu components.
To do so, simply add the component to the working area - the existing pages in your app will be automatically displayed there.
You can also add an item to your menu that will redirect users to an external link.
Another way to configure custom navigation in the app is by using our reusable header and sidebar options. You can select either of them in the right side panel, place a Menu component inside, and that's it. You don't have to add them to each page separately since they save their state across all app pages.
When using Link or Button components, you can pass dynamic parameters to a Detail page configuring the Query params property of the component. As an example, we'll review the case when you want to display the selected object on a child page on button click.
As a prerequisite, you already have a Table and Button components added to your working area.
First, navigate to the Pages tab in the left side panel and create a new page (we'll name it Customer since it will display customer details).
Add a Detail component on this page to display customer details.
Now, go back to the Home page, select the Button component and set the Customer page as the URL in the right side panel.
Next, in the Query params property, switch to JS mode and configure the primary key of the object:
In our example, the currently selected customer id will be sent as an id query parameter to the Customer page.
Next, create a new action of the Load Row type for your current Table.
In the Filters section, for customer_id specify the following variable to receive the URL query parameter on the child page:
{{activeRoute.queryParams.id}}
Assign the Load Row action to the Detail component on the Customer page.
That's it! Now, if you select a row in the Table and then click the Show customer button, you will navigate to the child page with the selected customer displayed in the Detail component.
External navigation can be also configured using components like Button, Menu, etc. Here, we'll review two use cases of configuring redirect to an external page.
Add a Button component to your working area.
Create a JavaScript Code action and specify the following code adding your external link:
or the following code to open the link in a new tab:
Assign this action to the button's On Click trigger.
Please be aware that when running this code on certain browsers, you may get a Blocked popup warning message. This is especially likely to occur when the code is executed using the Execute action button. However, if the code is executed as a result of user interaction (e.g. button click), it should function correctly.
Select your Menu component and clear the Update menu automatically checkbox in the right side panel.
Now, modify the Items property and add a new item that will redirect to an external page:
Next, navigate to the Triggers section of the component and create a new action for the On Item Click trigger.
Select a JavaScript Code action step and add the following code:
In this code, we use UI Bakery Docs as an example. Replace the URL with the one you want to open on clicking the new menu item.
Now, when clicking the new menu item, the external link will open in a new tab.
(Optional) If you want the external link to open in the same tab, you need to add the '_parent
' parameter to the following function:
Check out the pages below to learn more
Check out the instruction below