Magento2 – How to Specify Custom Template for Modal

magento2modal

How can I specify an custom template for an modal? I tried to specify the type and customTemplate, but no luck.
The template file is called modal-gallery.html and is placed on the same path as the modal-popup.

var modalOptions = {
    type: 'gallery',
    customTpl: 'gallery'
};
jQuery('<div />').modal(modalOptions).modal('openModal');

Best Answer

I found the answer by myself. You need to define 'text!ui/template/modal/modal-gallery.html' as galleryTpl and use the modalOptions as below:

var modalOptions = {
type: 'gallery',
customTpl: 'gallery',
galleryTpl: galleryTpl,
};