Giter Site home page Giter Site logo

jquery-modal-rails's Introduction

jquery-modal-rails

The simplest possible modal for jQuery for the Rails 3.1+ asset pipeline based on https://github.com/kylefox/jquery-modal

Usage

In your Gemfile, add:

group :assets do
  gem 'jquery-ui-rails'
  gem 'jquery-modal-rails'
end

Require Everything

To require the jQuery modal modules, add the following to your application.js:

//= require jquery.ui.all
//= require jquery.modal

Also add the jQuery modal CSS to your application.css:

/*
 *= require jquery.ui.all
 *= require jquery.modal
 */

All images required by jQuery Modal are automatically served through the asset pipeline, so you are good to go! For example, this code will open a given DIV as a modal dialog

<div id="demo-form" class="demo-description" style="display: none; ">
  <p>
    The basic dialog window is an overlay positioned within the viewport and is protected from page content
    (like select elements) shining through with an iframe. It has a title bar and a content area, and can be moved,
    resized and closed with the 'x' icon by default.
  </p>
</div>

<%=  link_to_modal "Demo Form", "#demo-form", :class=>"button" %>

Opening an existing view via AJAX as a modal dialog is that easy:

<%=  link_to_modal "New User", new_user_path, :class=>"button" %>

Forms-Support

The link_to_modal helper offers forms support. The following parameter ensures that every form which is part of the received html content will be submitted via AJAX request. As a requirement the controller action needs to support JSON

<%= link_to_modal 'New User', new_user_path, :remote => true %>

Cancel or Close buttons

All anchors generated with the link_to helper can be marked as a dialog close button. Just use the following sample:

<%= link_to 'Cancel', users_path, :rel => "modal:close" %>

Contributors

Thank you to the following wonderful people and projects for contributing to jquery-modal-rails:

jquery-modal-rails's People

Contributors

dei79 avatar

Watchers

James Cloos avatar  avatar

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.