In-Form Dropdown Menu Buttons

How to condense a Knack Menu into a categorized Dropdown Menu on each web page

Desktop Example from the Mobility Services Portal - Operating Authority Form
Mobile Example from the Mobility Services Portal - Operating Authority Form

The JS

There's customization that needs to go into the code before you can get it working in your app

  • Line 6-13: Links to the Page slug and creates a dictionary in the format

    • {"view_id" : ["Dropdown Menu Label", "page-slug"],etc...}

  • Line 17-24: Creates the dropdownMenuItem(slug, recordId, route, linkName) format

  • Line 27-47: Wraps the drop down menu based on the dictionary listing the Rich Text Views being replaced with dropdown menus.

    • Line 32-37: Creates HTML string using the dropdownMenuItem(recordId,route,linkName) function in line 4 per dropdown menu item in desktop.

    • Line 40-42: Creates HTML string using the dropdownMenuItem(recordId,route,linkName) function in line 4 per dropdown menu item in mobile screen sizes for min-width is 152px.

    • Line 45-47: Calls to render the dropdown menu item for desktop and mobile version using dropdownMenuItem(recordId,route,linkName)

The CSS

We style the menu buttons to be similar to how the default Knack styling is. We also hide the original menu view if screen size is 770px or larger but hide our custom dropdown menu on smaller screens. This allows for easier navigation on mobile without the dropdowns, but also easier navigation on desktop with the dropdowns.

Last updated

Was this helpful?