// initialize modal with options:
new NVJS_Modal(modalContainer, parameters);modalContainer- string (with CSS Selector) of NVJS_Modal container HTML element. Required;parameters- object with NVJS_Modal parameters. Optional.
example:
new NVJS_Modal({
modalShowClass: 'open',
modalShowButtons: '.show_modal'
})
modalShowButtons
Used for setshow modalon click this elements. May be string (with CSS Selector) or Array of strings (with CSS Selector)
typeStringorArray\
modalBody
String with CSS Selector of childNode ofmodalConteiner, which used for close modal. IfmodalBodyismodalContainer, closing element isdocument.body
typeString
default'.modal__container'
modalCloseButton
Used for setclose modalon click this elements. May be string (with CSS Selector) or Array of strings (with CSS Selector)
typeStringorArray
default'.modal__close'
modalShowClass
CSS class name added to modal elements when it becomes opened
typeString
default'open'
autoInitialize
Whether NVJS_Modal should be initialised automatically when you create an instance. If disabled, then you need to init it manually by calling mymodal.initialize()
typeBoolean
defaulttrue
lockBody
If enable, you can't scroll body, while modal is openned
typeBoolean
defaulttrue
logErrors
Show errors in console
typeBoolean
defaultfalse
example:
let myModal = new NVJS_Modal('.modal');
myModal.show()
.initialize();
Initialize NVJS_Modal if autoinitialize false in config
.toggle();
Hide modal if it was open and conversely
.hide();
Hide modal
.show();
Open modal
.header;
Header Element
example:
let myModal = new NVJS_Modal('.modal');
myModal.modal(addEventListener('show', () => {console.log('modal show')}))
show
When modal is open
hide
When modal is hide