Skip to content

Instantly share code, notes, and snippets.

@tbprojects
Created October 3, 2012 09:42
Show Gist options
  • Save tbprojects/3826096 to your computer and use it in GitHub Desktop.
Save tbprojects/3826096 to your computer and use it in GitHub Desktop.
[Rails][Javascript] link_with_confirm - colorbox dialog
= content_tag :div, id: 'destroy_confirmation' do
= content_tag :div, class: 'colorbox-head' do
= content_tag :h2, options[:title] || t("global.confirm_title")
= content_tag :div, class: 'colorbox-body' do
= content_tag :p, options[:message] || t('global.confirm')
= content_tag :div, class: 'colorbox-foot' do
= link_to t('global.yes'), confirmed_url,
method: (options[:method] || 'GET'),
remote: options[:remote],
class: 'bt bt-primary'
 
= link_to_function t('global.no'), '$.colorbox.close()', class: 'bt'
def link_with_confirm(name, url, html_options={})
html = render(partial: 'shared/confirmation_dialog/dialog', locals: {options: html_options, confirmed_url: url})
html.gsub!("\n","")
function = "$.colorbox({opacity: 0.5, html:'#{html}'})"
link_to_function name, function, html_options
end
# usage: link_with_confirm 'Remove', resource_url(supplier), method: :delete, message: t('.destroy_confirm_html')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment