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

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

WBOY
Release: 2016-05-16 18:16:28
Original
937 people have browsed it
复制代码 代码如下:

$.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');}});
})
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template