Home  >  Article  >  Web Front-end  >  Encapsulate the easyui-Dialog plug-in implementation code _jquery this time

Encapsulate the easyui-Dialog plug-in implementation code _jquery this time

WBOY
WBOYOriginal
2016-05-16 18:16:28918browse
复制代码 代码如下:

$.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('
');
$('#' id "_content").html(options.html);
}
createContent();
}

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

$(function(){
  var d =$('
');
  $('#d').hDialog({submit:function(){$(d).dialog('close');}});
})
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn