Sha256: c0c15f5112d1d17aef9ad1b143ed2ef2339d38d6117217d491304c1f137bebee

Contents?: true

Size: 891 Bytes

Versions: 50

Compression:

Stored size: 891 Bytes

Contents

# 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], 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

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
wrgem-0.0.55 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/confirm.coffee
wrgem-0.0.54 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/confirm.coffee
wrgem-0.0.53 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/confirm.coffee
wrgem-0.0.52 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/confirm.coffee
wrgem-0.0.51 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/confirm.coffee
wrgem-0.0.50 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/confirm.coffee
wrgem-0.0.49 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/confirm.coffee
wrgem-0.0.48 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/confirm.coffee
wrgem-0.0.47 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/confirm.coffee
wrgem-0.0.46 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/confirm.coffee
wrgem-0.0.45 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/confirm.coffee
wrgem-0.0.44 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/confirm.coffee
wrgem-0.0.43 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/confirm.coffee
wrgem-0.0.42 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/confirm.coffee
wrgem-0.0.41 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/confirm.coffee
wrgem-0.0.40 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/confirm.coffee
wrgem-0.0.39 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/confirm.coffee
wrgem-0.0.38 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/confirm.coffee
wrgem-0.0.37 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/confirm.coffee
wrgem-0.0.35 lib/generators/wrstart/template/vendor/assets/components/rails-behaviors/confirm.coffee