constructor
function layer_custom() {
this.json = {
type: "",
title: null,
content: "",
area: "",
//skin:"layui-layer-rim",
//offset:
btnAlign: "c",
closeBtn: null,
// shade: 0,
shade: [.1, "-sharp000"],
shadeClose: false,
time: 0,
id: "onlyOne",//id
anim: 0,
resize: false,
yes: null,
no: null,
cancel: null,
btn1: null,
btn2: null,
btn3: null
}
}
instance method
// 3
layer_custom.prototype.alertCustBtn = function(id, title, Arrbtn, content, area, fn, fn1, fn2, suc, destory) {
this.json.type = 1;
this.json.id = id;
this.json.btn = Arrbtn; //Arrbtn
this.json.title = title;
this.json.closeBtn = 1;
this.json.content = content;
this.json.area = area;
this.json.btn1 = function(index, layero) {
fn && fn(index);
// layer.close(index);
};
this.json.btn2 = function(index) {
fn1 && fn1(index);
// layer.close(index);
};
this.json.btn3 = function(index) {
fn2 && fn2(index);
// layer.close(index);
};
this.json.success = function() {
suc && suc();
}
this.json.end = function() {
destory && destory();
}
layer.open(this.json);
};
calling code
var did = "dialog1";
//layer_customiddialog1
//alertCustBtndialog1
$layer.alertCustBtn(did, "", [""], "", ["840px", "600px"], (index) => {
layer.close(index);
}, null, null, () => {
_tpl.layuiTplRender("caseDetailPanel_tpl", did, {});
});
at present, the id on layer_custom is overwritten as dialog1.
but the value on the constructor becomes dialog1 the next time you call alertCustBtn. Can you make the constructor not record the last value passed, but use the default attribute value on the constructor every time I call the instance method without overwriting the property?