lazy-modal
show bootstrap modal with lazy load. sometimes we have too many modals in html body. and u know always some modal not need rendered. the best pratice to show modal i think is lazy load modal. bootstrap modal plugin provide remote away the load modal content when needed. this gem provide way load bootstrap modal from remote server. so that we can load the modal when needed it. it's start!
Usage
How to lazy-modal it's too simplest!
Add this line to your rails application's Gemfile:
gem 'lazy_modal'
And then execute:
$ bundle
Auto init lazy_modal required file
$ rails generate lazy_modal:install
That's all!
Now test if lazy-modal installed?
Start server
$ rails s
open below url in any browse http://localhost:3000/lazy_modals/demo, u will see a break style modal demo
Options
You can trigger lazy_modal below way:
<%= link_to 'demo', '#demo', data: {lazy_modal: true, modal_options:{dir: 'custom_modals', title: 'loading', size: 'modal-sm', target: 'demo', id: 'demo'}} %>
You must set a tag with data-lazy-modal=true and use modal_options to custom modal
| ModalOptions | Type | Remark |
|---|---|---|
| id/target/href | string | required, modal id like: #charge_modal |
| dir | string | optional,u should set u modal view dir name like: users mean's find modal in app/views/users/modal_id |
| title | string | optional,before load remote modal, u will see simple load modal with placeholder, so the options set the modal title |
| size | string | optional,before load remote modal, u will see simple load modal with placeholder, so the options set the modal-content with custom class like: `modal-sm |
License
The gem is available as open source under the terms of the MIT License.