×

在次封装easyui-Dialog插件实现代码

作者:Terry2017.02.11来源:Web前端之家浏览:8874评论:0
关键词:JQueryJS
复制代码 代码如下:

$.fn.hDialog = function (options) {
var defaults = {
width: 300,
height: 200,
title: '此处标题',
html: '',
iconCls: '',
submit: function () { alert('可执行代码.'); }
}
var id = $(this).attr('id');
options = $.extend(defaults, options);
var self = this;

$(self).dialog({
title: options.title,
height: options.height,
width: options.width,
iconCls: options.iconCls,
buttons: [{
text: '确定',
iconCls: 'icon-ok',
handler: options.submit
}, {
text: '取消',
iconCls: 'icon-cancel',
handler: function () {
$('#' + id).dialog('close');
}
}]
});

function createContent() {
$('.dialog-content',$(self)).empty().append('<div id="' + id + '_content" style="padding:5px;"></div>');
$('#' + id + "_content").html(options.html);
}
createContent();
}

调用:
复制代码 代码如下:

$(function(){
  var d =$('<div id="d"></div>');
  $('#d').hDialog({submit:function(){$(d).dialog('close');}});
})

您的支持是我们创作的动力!
温馨提示:本文作者系Terry ,经Web前端之家编辑修改或补充,转载请注明出处和本文链接:
https://jiangweishan.com/article/svg1486742400684.html

网友评论文明上网理性发言已有0人参与

发表评论: