$Modal support render, fixed #1041

This commit is contained in:
Aresn 2017-06-02 10:04:49 +08:00
parent dce5a3ea6b
commit 3ef24d5fe5
4 changed files with 56 additions and 22 deletions

View file

@ -48,6 +48,35 @@ Modal.newInstance = properties => {
}
}, this.localeOkText));
// render content
let body_render;
if (this.render) {
body_render = h('div', {
attrs: {
class: `${prefixCls}-body ${prefixCls}-body-render`
}
}, [this.render(h)]);
} else {
body_render = h('div', {
attrs: {
class: `${prefixCls}-body`
}
}, [
h('div', {
class: this.iconTypeCls
}, [
h('i', {
class: this.iconNameCls
})
]),
h('div', {
domProps: {
innerHTML: this.body
}
})
]);
}
return h(Modal, {
props: Object.assign({}, _props, {
width: this.width,
@ -81,24 +110,7 @@ Modal.newInstance = properties => {
}
})
]),
h('div', {
attrs: {
class: `${prefixCls}-body`
}
}, [
h('div', {
class: this.iconTypeCls
}, [
h('i', {
class: this.iconNameCls
})
]),
h('div', {
domProps: {
innerHTML: this.body
}
})
]),
body_render,
h('div', {
attrs: {
class: `${prefixCls}-footer`

View file

@ -2,18 +2,20 @@ import Modal from './confirm';
let modalInstance;
function getModalInstance () {
function getModalInstance (render = undefined) {
modalInstance = modalInstance || Modal.newInstance({
closable: false,
maskClosable: false,
footerHide: true
footerHide: true,
render: render
});
return modalInstance;
}
function confirm (options) {
let instance = getModalInstance();
const render = ('render' in options) ? options.render : undefined;
let instance = getModalInstance(render);
options.onRemove = function () {
modalInstance = null;