Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kanety/jquery-simple-modal
https://github.com/kanety/jquery-simple-modal
Last synced: 8 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/kanety/jquery-simple-modal
- Owner: kanety
- License: mit
- Created: 2019-09-01T08:06:22.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-10-21T01:16:01.000Z (about 5 years ago)
- Last Synced: 2024-12-25T04:04:43.637Z (23 days ago)
- Language: JavaScript
- Size: 12.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# jquery-simple-modal
A jquery plugin for simple modal.
## Dependencies
* jquery
## Installation
Install from npm:
$ npm install @kanety/jquery-simple-modal --save
## Usage
Build html as follows:
```html
content
content
OK
Cancel
Open
```Then run:
```javascript
$('#content').simpleModal({
opener: '#open',
closer: '#ok,#cancel'
});
```### Options
Focus elements when modal is opened:
```javascript
$('#content').simpleModal({
focus: '#ok'
});
```Set modal owner element:
```javascript
$('#content').simpleModal({
owner: '#element'
});
```Disable modal closing for specific events:
```javascript
$('#content').simpleModal({
closeByEsc: false, // ESC key
closeByModalClick: false // click modal background
});
```### Callbacks
Run callbacks when a modal is opened or closed:
```javascript
$('#content').simpleModal({
...
}).on('modal:open', function(e, $handler) {
console.log("opened by " + $handler.attr('id'));
}).on('modal:close', function(e, $handler) {
console.log("closed by " + $handler.attr('id'));
});
```## License
The library is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).