Edit this page

up.radio up.radio.startPolling(fragment, [options])
JavaScript function

Starts polling the given element.

The given element does not need an [up-poll] attribute.


General

fragment
required

The fragment to reload periodically.

[options]
optional

Options for reloading the fragment.

By default Unpoly will parse options from the fragment's attributes (see [up-poll]). You may pass this additional options object to supplement or override options parsed from the fragment's attributes.

Trigger

[options.interval]
optional

The reload interval in milliseconds.

Defaults to up.radio.config.pollInterval.

number
[options.ifLayer='front']
optional

Controls polling while the fragment's layer is covered by an overlay.

When set to 'front', polling will pause while the fragment's layer is covered by an overlay. When the fragment's layer is uncovered, polling will resume.

When set to 'any', polling will continue on background layers.

string

Request

[options.url]
optional

The URL from which to reload the fragment.

Defaults to the URL this fragment was originally loaded from.

string
[options.method='get']
optional

The HTTP method used to reload the fragment.

string
[options.headers={}]
optional

A JSON object with additional request headers.

string
[options.params={}]
optional

A JSON object with additional parameters that should be sent as the request's query string or payload.

When making a GET request to a URL with a query string, the given { params } will be added to the query parameters.

string

Client state

[options.keepData=false]
optional

Whether to preserve the polling fragment's data object through reloads.

boolean

Loading state

[options.disable]
optional

Disables form controls while the request is loading.

booleanstringElementArray
[options.placeholder]
optional

A placeholder to show within the targeted fragment while new content is loading.

Existing children of the targeted fragment will be hidden during the request. When the request ends for any reason, all changes will be reverted.

stringElementList<Node>
[options.preview]
optional

One or more previews that temporarily change the page while new content is loading.

The preview changes will be reverted automatically when the request ends for any reason.

stringFunction(up.Preview)Array
[options.feedback=true]
optional

Whether to set feedback classes while loading content.

boolean