>  기사  >  웹 프론트엔드  >  이번에는 easyui-Dialog 플러그인 구현 코드 _jquery를 캡슐화합니다.

이번에는 easyui-Dialog 플러그인 구현 코드 _jquery를 캡슐화합니다.

WBOY
WBOY원래의
2016-05-16 18:16:28870검색
复제대码 代码如下:

$.fn.hDialog = 기능(옵션) {
var 기본값 = {
너비: 300,
높이: 200,
제목: '此处标题',
html: '',
iconCls: '',
제출: 기능 () { Alert('可执行代码.'); }
}
var id = $(this).attr('id');
옵션 = $.extend(기본값, 옵션);
var self = this;

$(self).dialog({
제목: options.title,
높이: options.height,
너비: options.width,
iconCls: options.iconCls,
버튼: [{
텍스트: '确정',
iconCls: 'icon-ok',
handler: options.submit
}, {
text: '取消',
iconCls: 'icon-cancel',
핸들러: 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으로 문의하세요.