Sweetalert

A ruby gem for sweetalert developed by t4t5 A beautiful replacement for JavaScript's "alert"

Sweet Alert in Action

Live Demo

Installation

Add this line to your application's Gemfile:

gem 'sweetalertify'

And then execute:

$ bundle

Or install it yourself as:

$ gem install sweetalertify

Usage

To your application.js file, add:

//= require sweetalert-dev

Then, in your application.css, add:

@import "sweetalert";

Basic message:

swal("Hello world!");

A warning message, with a function attached to the "Confirm"-button:

swal({
  title: "Are you sure?",
  text: "You will not be able to recover this imaginary file!",
  type: "warning",
  showCancelButton: true,
  confirmButtonColor: "#DD6B55",
  confirmButtonText: "Yes, delete it!",
  closeOnConfirm: false,
  html: false
}, function(){
  swal("Deleted!",
  "Your imaginary file has been deleted.",
  "success");
});

Customizations

Visit the official Sweetalert repo for customizations and a more detailed usage guide

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/rahullakhaney/sweetalert.

Follow me on Twitter to see my #20in20 challenge

License

The gem is available as open source under the terms of the MIT License.