Edit this page

up.fragment :maybe
HTML selector

Marks a target selector as optional.

If a :maybe selector is not found in the current page or the server response, Unpoly will skip rendering the fragment instead of throwing an error.

An optional selector will be omitted from an X-Up-Target header unless it matches in the current page.

Dealing with missing targets

Example

When updating multiple fragments you may combine required and optional selectors in a single target string.

The link below will update the fragments .content (required) and .details (optional):

<a href="/card/5" up-target=".content, .details:maybe">...</a>

Only the fragment .content is required to match. If .details is missing in the current page or the server response, Unpoly will only update .content without an error.