Skip to content

mkhairi/alertifyjs-rails

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

alertifyjs-rails Gem Version

This gem provides alertify.js for Rails.

Installation

In your Gemfile:

gem 'alertifyjs-rails'

or system wide:

$ gem install alertifyjs-rails

Usage

The alertify files will be added to the asset pipeline and available for you to use. Add the following line to app/assets/javascripts/application.js

//= require alertify

Optional js(coffe script) replace browser confirm dialog

  • if you use jquery-ujs
//= require alertify/confirm-modal
  • if you use rails-ujs (default rails 5)
//= require alertify/confirm-ujs

In order to get the CSS, add the following line to app/assets/stylesheets/application.css

/*
 *= require alertify
 *= require alertify/default
 *= require alertify/bootstrap
 */

or if you using scss app/assets/stylesheets/application.scss

 @import "alertify";
 @import "alertify/default";
 @import "alertify/bootstrap";

flash helper, add the following line in layout

<head>
<%= alertify_flash %>
</head>

or with wait timeout option

<head>
<%= alertify_flash(wait: 20) %>
</head>

or in your js request format

<%= alertify_flash_now %>

**notes The default content security policy for Rails 5.2 blocked the functionality of this flash helper. An initial workaround is to add :unsafe_inline as an option to the policy.script_src in development

policy.script_src  :self, :https, :unsafe_inline

More option? read alertify.js documentation here