Skip to content

Latest commit

 

History

History

pages_keep_state

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Pages-keep-state example

How to create and browse multiple pages in your app, demonstrating lazy loading model values and persisting selected page state across page loads.

The pattern used in this example is probably better suited to more complex websites or apps where you want to keep model state across page loads, e.g. where there are many filters configurable by the user or there are time-consuming init operations such as multiple fetches.

In this example the current page is stored in Model.page_id and Model.admin_model represents the admin report subpage selected by the user.

Lazy model initialization is used and the report subpage selection persists until changed by the user.

To see this in action, follow these steps:

  1. Open the example and select report. Notice the page text "This is your daily report".
  2. Select Switch to weekly. Notice the page text "This is your weekly report".
  3. Select Home then Report. The report page persists at "This is your weekly report".

The pages example pattern is simpler and maybe more predictable, without lazy model loading or page state persistence.


cargo make start

Open 127.0.0.1:8000 in your browser.