ホームページ  >  記事  >  ウェブフロントエンド  >  在次封装easyui-Dialog插件实现代码_jquery

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

WBOY
WBOYオリジナル
2016-05-16 18:16:28869ブラウズ
复制代码 代码如下:

$.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');}});
})
声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。