Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding docs for script_paths for Gui & Page #1256

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions docs/userman/gui/pages/advanced/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,48 @@ You can indicate, using the parameter *path_mapping* of the
`Gui.__init__^`(`Gui` constructor), where those resources are located on the file
system.

## Using JavaScript scripts

Sometimes, you might need to include JavaScript files in your application.<br/>
You can do this by specifying the file path in the *script_paths* parameter of the
`Gui.__init__()^`(`Gui` constructor). For instance, if you have a JavaScript file named
`my_script.js` in the same directory as your Python script, you can include it like this:

!!! example

Here is an example of how to include a JavaScript file in your application:
```python
from taipy import Gui

Gui(page="Hello, world!", script_paths=["my_script.js"]).run()
```

When you run this application, your JavaScript file will be included in all the pages of the application.

If you need to include a JavaScript file on a specific page only, you can do so by using the
*script_paths* parameter of the `Page.__init__()^`(`Page` constructor). For example, if you have two pages
and want to include a JavaScript file only on the second page, here's how you can do it:

!!! example

Here is an example of how to include a JavaScript file in a specific page:
```python
from taipy import Gui, Page

page1 = Page("Hello, world!")
page2 = Page("Hello, world!", script_paths=["my_script.js"])

Gui(pages={"page1": page1, "page2": page2}).run()
```

When you run this application, your JavaScript file will be included only in the second page.

!!! note "JavaScript file path configuration"

The *script_paths* parameter loads specified JavaScript files when rendering the page.
This ensures the script is available and ready to use when the page is loaded by the browser.
You should make the file path is accurate and correctly points to the location of the script file, relative to the Python script.

## Status page

The *Status* page is a special page that the user can access by requesting the page at
Expand Down