Edit this page

up.link up.follow(link, [options])
JavaScript function

Follows the given link with JavaScript and updates a fragment with the server response.

By default the layer's main element will be replaced. Attributes like [up-target] or [up-layer] will be honored.

Following a link is considered navigation by default.

Emits the event up:link:follow.

Examples

Assume we have a link with an [up-target] attribute:

<a href="/users" up-target=".main">Users</a>

Calling up.follow() with this link will replace the page's .main fragment as if the user had clicked on the link:

var link = document.querySelector('a')
up.follow(link)

Parameters

[options] Object optional

Render options that should be used for following the link.

Unpoly will parse render options from the given link's attributes, like [up-target] or [up-transition]. See [up-follow] for a list of supported attributes.

You may pass this additional options object to supplement or override options parsed from the link attributes.

[options.navigate=true] boolean optional

Whether this fragment update is considered navigation.

Setting this to false will disable most defaults, causing Unpoly to render a fragment without side-effects like updating history or scrolling.

Return value

A promise that fulfills with an up.RenderResult once the link destination has been loaded and rendered.