Load more tasks
\#\#\#\# Following on mousedown
By also adding an `up-instant` attribute, the page will be fetched
on `mousedown` instead of `click`, making the interaction even faster:
User list
Note that using `[up-instant]` will prevent a user from canceling a link
click by moving the mouse away from the interaction area. However, for
navigation actions this isn't needed. E.g. popular operation
systems switch tabs on `mousedown`.
@method a[up-target]
@ujs
@param {String} up-target
The CSS selector to replace
@param up-instant
If set, fetches the element on `mousedown` instead of `click`.
This makes the interaction faster.
###
up.on 'click', 'a[up-target]', (event, $link) ->
event.preventDefault()
# Check if the event was already triggered by `mousedown`
unless $link.is('[up-instant]')
follow($link)
up.on 'mousedown', 'a[up-target][up-instant]', (event, $link) ->
if activeInstantLink(event, $link)
event.preventDefault()
up.follow($link)
###*
@method up.link.childClicked
@private
###
childClicked = (event, $link) ->
$target = $(event.target)
$targetLink = $target.closest('a, [up-follow]')
$targetLink.length && $link.find($targetLink).length
activeInstantLink = (event, $link) ->
u.isUnmodifiedMouseEvent(event) && !childClicked(event, $link)
###*
If applied on a link, Follows this link via AJAX and replaces the
current `` element with the response's `` element
User list
\#\#\#\# Following on mousedown
By also adding an `up-instant` attribute, the page will be fetched
on `mousedown` instead of `click`, making the interaction even faster:
User list
Note that using `[up-instant]` will prevent a user from canceling a link
click by moving the mouse away from the interaction area. However, for
navigation actions this isn't needed. E.g. popular operation
systems switch tabs on `mousedown`.
\#\#\#\# Enlarging the click area
You can also apply `[up-follow]` to any element that contains a link
in order to enlarge the link's click area:
In the example above, clicking anywhere within `.notification` element
would follow the *Close* link.
@method [up-follow]
@ujs
@param {String} [up-follow]
@param up-instant
If set, fetches the element on `mousedown` instead of `click`.
###
up.on 'click', '[up-follow]', (event, $link) ->
unless childClicked(event, $link)
event.preventDefault()
# Check if the event was already triggered by `mousedown`
unless $link.is('[up-instant]')
follow(resolve($link))
up.on 'mousedown', '[up-follow][up-instant]', (event, $link) ->
if activeInstantLink(event, $link)
event.preventDefault()
follow(resolve($link))
###*
Marks up the current link to be followed *as fast as possible*.
This is done by:
- [Following the link through AJAX](/up.link#up-target) instead of a full page load
- [Preloading the link's destination URL](/up.proxy#up-preload)
- [Triggering the link on `mousedown`](/up.link#up-instant) instead of on `click`
Use `up-dash` like this:
User list
Note that this is shorthand for:
User list
You can also apply `[up-dash]` to any element that contains a link
in order to enlarge the link's click area: