Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

42 lines (40 sloc) 0.925 kB
# Confirm
#
#= require ./prepare
#
# Prompts native confirm dialog before activating link.
#
# ### Markup
#
# `<a>`
#
# ``` definition-table
# Attribute - Description
#
# `data-confirm` - Message to pass to `confirm()`.
# ```
#
# ``` html
# <a href="/" data-confirm="Are you sure?">Delete</a>
# ```
#
# `<button>`
#
# ``` definition-table
# Attribute - Description
#
# `data-confirm` - Message to pass to `confirm()`.
# ```
#
# ``` html
# <button type="submit" data-confirm="Are you sure?">Delete</a>
# ```
$(document).on 'click:prepare', 'a[data-confirm], input[type=submit][data-confirm], button[data-confirm]', (event) ->
if message = $(this).attr 'data-confirm'
# Prompt message with native confirm dialog
unless confirm message
# Prevent other handlers on the document from running
event.stopImmediatePropagation()
# Prevent default action from running
event.preventDefault()
return
Jump to Line
Something went wrong with that request. Please try again.