Giter VIP home page Giter VIP logo

sweet-alert-rails-confirm's People

Contributors

adamrubin avatar adrianoresende avatar akz92 avatar ayezee33 avatar emilkarl avatar ghaydarov avatar jmbejar avatar markhazlett avatar maxhs avatar mois3x avatar pcriv avatar roclv avatar shaun27stars avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sweet-alert-rails-confirm's Issues

Skips confirm dialog on link_to in Rails 3.2.14 app

My links work normally without the gem:

<%= link_to 'Delete', book, confirm: 'Are you sure?', method: :delete, remote: true %>

But when I add the gem the dialog is skipped entirely and the record is deleted without confirmation.

A regular Sweet Alert dialog works with: sweetAlert('Hello'); on the same page but the confirms fail.

It all works fine in a blank Rails 4.2 app but is failing in my 3.2.14 production app. May be a JS conflict? Any ideas where I can start debugging it?

My Gemfile:

ruby '1.9.3'

gem 'rails', '3.2.14'

group :development do
  gem 'hirb'
  gem 'rails-erd'
  gem 'quiet_assets'
  gem "bullet"
  gem 'traceroute'
  gem 'meta_request'
  gem 'thin'
end

group :development, :test do
  gem 'rspec-rails', '~> 2.14.1'
end

group :test do
  gem 'factory_girl_rails', '~> 4.2.1'
  gem 'faker', '1.3.0'
  gem 'capybara', '~> 2.1.0'
  gem 'database_cleaner', '~> 1.0.1'
  gem 'launchy', '~> 2.3.0'
  gem 'selenium-webdriver', '~> 2.38.0'
  gem 'poltergeist', '1.5.1'
  gem 'rb-fsevent', :require => false if RUBY_PLATFORM =~ /darwin/i
  gem 'guard-rspec'
  gem 'spork-rails'
  gem 'guard-spork'
end

gem 'pg', '0.17.0'

group :assets do
  gem 'sass-rails',   '~> 3.2.6'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

gem 'simple_form' 
gem 'garlicjs-rails' 
gem 'figaro' 
gem 'devise',           '~> 3.0.0'
gem 's3_direct_upload' 
gem 'paperclip'  
gem 'aws-sdk' 
gem 'cancan'
gem 'will_paginate', '~> 3.0.5'
gem 'ruby-oembed' 
gem 'aws_sns_subscription'
gem 'mandrill-api',     '~> 1.0.51'  
gem 'mobvious' 
gem 'mobvious-rails' 
gem 'active_importer', github: 'continuum/active_importer', branch: 'develop'
gem 'google_drive'
gem 'google-spreadsheet-ruby'
gem 'spreadsheet'
gem 'delayed_job_active_record'
gem "daemons"
gem "workless", '~> 1.2.3'
gem 'sass', '3.2.15'
gem 'stripe', :git => 'https://github.com/stripe/stripe-ruby'
gem 'intercom-rails', github: 'krismartin/intercom-rails', branch: 'feature/allow-nil-inbox-style'
gem 'paper_trail', '~> 3.0.6'
gem 'simplecov', :require => false, :group => :test
gem 'client_side_validations'
gem 'client_side_validations-simple_form'
gem 'autoprefixer-rails'
gem "sentry-raven"
gem 'sweet-alert-confirm', git: 'https://github.com/mois3x/sweet-alert-rails-confirm'

gem 'newrelic_rpm'
gem 'rails_12factor', group: :production
gem 'unicorn'

couldn't find file 'sweet-alert-confirm'

I'm trying to implement the gem with the readme instructions, in my Gemfile I have the following code:

source "https://rails-assets.org" do
  gem "rails-assets-sweetalert", "~> 1.1.3"
end

In my application.js

//= require sweetalert
//= require sweet-alert-confirm

But when I start my local server I get this error:

couldn't find file 'sweet-alert-confirm' with type 'application/javascript'

Any idea?

Does not work with button_to

The button_to view helper is not implemented.

This works:

<%= button_tag "Delete", data: { confirm: "Are you sure?" } %>

But this doesn't:

<%= button_to "Delete", "#", data: { confirm: "Are you sure?" } %>

EDIT:

Of course this fixes the problem:

<%= button_to "Delete", "#", data: { "sweet-alert-confirm": "Are you sure?" } %>

alert not shown on ajax complete

Hello,

The sweet alert confirm dialog does not work after an ajax request completes: for example when using link_to with remote: true several times on the same page, the confirm dialog works only the first time an ajax call is made. I think the confirm dialog should be initialized after ajax callback events especially ajaxComplete.

Rdgs,
Ismael

not working

Is it working now? This is what the button_tag render for me

<button class="btn btn-system" data-sweet-alert-confirm="Are you sure?" data-sweet-alert-type="info" name="button" type="submit">Test</button>

nothing happens when i clicked the button? please help

Support button_tag?

Wondering if you could add support for button_tag elements. Not sure if this is 100% correct, but the code below worked for me. If you prefer, I can put in a pull request.

def button_tag(*args, &block)

  html_options = args[block_given? ? 0 : 1] || {}

  if options_has_confirm?(html_options)
    html_options['data-sweet-alert-confirm'] = html_options.delete(:confirm) ||
                html_options[:data].delete(:confirm)
  end
  super *args, &block

end

bundle install doesnt work

Tried installing gems as said in the readme but it fails both on ruby 1.9.3-p551 and 2.2.2

$ RAILS_VERSION=4.1.2 bundle install                                                                                            

Your Gemfile lists the gem poltergeist (>= 0) more than once.
You should probably keep only one of them.
While it's not a problem now, it could cause errors if you change the version of just one of them later.
Fetching git://github.com/rails/sass-rails.git
Fetching gem metadata from https://rubygems.org/...........
Fetching additional metadata from https://rubygems.org/..
Resolving dependencies...
Could not find gem 'sprockets (>= 4.0) ruby', which is required by gem 'sass-rails (>= 0) ruby', in any of the sources.

html safe text doesn't work

swal({   
            html: true,
            title: "Register in this course?",   
            text: "<ul style='text-align: left;'><li>You can only unregister by contacting the admins</li><li>You will be able to rate the course by the end of the semester</li><li>You will be able to add/remove Professors and Teaching Assistants</li><li>You will be notified with any changes within the course</li><li>You can register in 10 courses per semester only</li></ul>",
            type: "info",   
            showCancelButton: true,   
            confirmButtonColor: "#5cb85c",
            confirmButtonText: "Register"
        })

I can set all the options like that swal js call. but not the html: true it just doesn't work. why is that?

That's my erb code

<%= link_to "Register in this course", register_semester_course_path(@semester_course), method: :post, data: { 'html': true, confirm: 'Register in this course?', text: "<ul style='text-align: left;'><li>You can only unregister by contacting the admins</li><li>You will be able to rate the course by the end of the semester</li><li>You will be able to add/remove Professors and Teaching Assistants</li><li>You will be notified with any changes within the course</li><li>You can register in 10 courses per semester only</li></ul>",  'confirm-button-text': 'Register', 'confirm-button-color': '#5cb85c', 'sweet-alert-type': 'info' }, class: "btn btn-success" %>

showConfirmButton: false doesn't work

In my Rails 4 application I'm using sweet alert to show notice and alert flash messages. I have the following in my application.js

$(document).ready(function(){
  "use strict";

  // show flash messages if any
  if($(".flash-message").length){
    var key = $(".flash-message").attr("key");
    var value = $(".flash-message").attr("value");
    showNotificationMessage(key, value);
  }
});

function showNotificationMessage(key, value){
  if(key === "success" || key === "notice"){
    swal({
      title: value,
      type: "success",
      timer: 3000,
      showConfirmButton: false,
    });
  }
  else{
    swal({
      title: value,
      type: "error",
      timer: 3000,
      showConfirmButton: false,
    });
  }
}

However, sweetalert still shows an ok button. Is this a current issue? or is there a way around it?

Animation

Hy!!

How can i disable animation? If isnt any in gems to support it, how can i hardly change it to no animation?

Thanks!

Uncaught TypeError: Cannot read property 'handleMethod' of undefined

Running into JavaScript error after the dialogue pops up, When I try to click any of the two options

Uncaught TypeError: Cannot read property 'handleMethod' of undefined

I am using Rails 4.0.0

The script is runing into an error at line 44
$.rails.handleMethod($linkToVerify)

Linkto Verify is defined as

$linkToVerify = $(this)

I think this is not referenced...

Submit button_tag with confirm not sent in form params

Hello,

In my app I use Fontawesome icons so my submit tags use button_tag helper in order to make the icons appear. I have the following issue:

This works :

<%= button_tag name: 'commit', class: "btn btn-secondary btn-sm", title: "Supprimer définitivement", value: 'Delete' do %> <%= icon('trash', '') %> <% end %>
with the following logs:

Parameters: {"utf8"=>"✓", "authenticity_token"=>"wSx7XnfCN2jYUiyNDNsn3oQt2EXkpcx3pwg3Lue+wNMgVC0/VR67cRYq3TQZBKjKffYDqKSJkrHEHvogu7GuIg==", "commit"=>"Delete", "conversation_ids"=>["cd65e468-54c8-4256-85be-d2c928f932c7"]}

But when I want to confirm with the user like this:

<%= button_tag name: 'commit', class: "btn btn-secondary btn-sm", title: "Supprimer", value: 'Delete', data: {:confirm => 'Êtes vous sûr?', :'confirm-button-text' => 'Ohh oui', :'cancel-button-text' => 'Ooops!', :'confirm-button-color' => '#1ab394', :'sweet-alert-type' => 'info', text: 'Cette action est irréversible'} do %> <%= icon('trash', '') %> <% end %>

the form is submitted without the commit param:

Parameters: {"utf8"=>"✓", "authenticity_token"=>"k2UqZPiA88FGKxd3T8RQjy1yhqdFILuHlvNwX86s5rhyHXwF2lx/2IhT5s5aG9+b1KldSgUM5UH15b1RkqOISQ==", "conversation_ids"=>["cd65e468-54c8-4256-85be-d2c928f932c7", "5a8f5971-ed74-4fe1-9011-1d7cf70b55d1"]}

Thanks for your help.

response from js.erb is not executed for remote link with ajax

Hello,

First of all, thanks for this gem, it is really helpfull for making beautiful confirm for Rails apps.

I have an issue with it though: the gem seems to break Rails 4.0.2beta4 jquery UJS when used with link_to helper with remote: true. Clearly, the JS response returned by the server is not executed by the browser directly even though it can be executed in Firebug/Chrome console. I suspect this is due to the data-type option passed to the link_to helper, this may be confusing Rails and the request is treated as " / " and not as " JS ". A solution could be to rename the data-type option to something like data-sweet-alert-type and then pass that iption value to sweet-alert JS.

Could you fix this or help me by pointing me to the right place in the code where to test the idea?

Regards,
Ismael

How i call function after confirm?

How i make function after click confirm in Rails?
Exemple javascript:

swal(
    { ... },
    function(isConfirm){
        ...
    }
);

Exemple HTML Rails:

<%= link_to raw('<i class="fa fa-trash-o"></i>'),
                       admin_remover_imovel_foto_path(:asset_id => asset.id),
                       :remote   => true,
                       :method   => :post,
                       :class    => 'remove-archive',
                       :data     => { 
                           :confirm => 'Are you sure?',
                           // :function => javascript function?
                       }
%>

Ajax Completion Event Causing Multiple DIVs

Not quite sure of the fix, but I can look into it (more what the repercussions might be) but it looks like the the code called on AJAX completion is re-triggering the SweetAlert initialization routine, which appends an overlay and alert container to the DIV. If you have a page with heavy AJAX interaction, you end up with a lot of extra sweet alert overlays and containers at the bottom of the body.

The code that causes it:

  $(document).on('ready page:change ajaxComplete', function() {
    $('[data-sweet-alert-confirm]').on('click', sweetAlertConfirm)
    //To avoid "Uncaught TypeError: Cannot read property 'querySelector' of null" on turbolinks
    window.sweetAlertInitialize();
  });

Which calls this in the core sweet alert:

  /*
   * Add modal + overlay to DOM
   */
  window.sweetAlertInitialize = function() {
    var sweetHTML = '<div class="sweet-overlay" ... long line removed ... </div>',
        sweetWrap = document.createElement('div');

    sweetWrap.innerHTML = sweetHTML;

    // Append elements to body
    while (sweetWrap.firstChild) {
      document.body.appendChild(sweetWrap.firstChild);
    }
  };

I don't know if the correct place to put the fix is probably in the Sweet Alert library (no reason to add the elements if they already exist) or in the sweet alert confirm code (don't reinitialize if it exists). I see there is a comment about turbolinks in this - but I don't know the reasoning there, without digging deeper.

Any thoughts?

Did not work with form submit button

Just tried this gem and it worked fine using data-confirm in a link_to object, but it did not work with data-confirm on a form submit button.

Using Rails 4.0.1

Does not work with turbolinks

Is there a way to make this work with turbolinks/jquery.turbolinks? In my experience it skips the confirmation modal and executes the button action straight away.

Export is not Defined after upgrading to latest version

After updating I am not getting the following:
Uncaught ReferenceError: exports is not defined(anonymous function) @ sweet-alert.self.js?body=1:5

Gem Versions:

  • sweet-alert (0.0.9)
    • sweet-alert-confirm (0.4.1)

Any ideas?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.