EasyUI Dialog Buttons 绑定click事件

1、jsp页面定义dialog及Buttons;
<div id="win" style="padding: 5px" modal=true draggable=false class="easyui-dialog" closed=true
     data-options="
			buttons:[{
				text:'save',
			},{
				text:'close',
			}]">

2、js文件方法;

//buttons text取值!

$.extend($.fn.dialog.methods, {
        bindButtonEvents: function (jq, param) {
            return jq.each(function () {
                var dialog = $(this);
                dialog.parent().on('click', '.dialog-button a', function (e) {
                    var text = $(this).linkbutton('options').text;
                    var method = param[text];
                    if (method) { method(); }
                });
            });
        }
    });
//dialog按钮方法
    $('#win').dialog('bindButtonEvents', {
        save: function () {
            console.log('hellolllllll')
        },
        close: function () {
            console.log('close..............')

        }
    });

猜你喜欢

转载自leiding.iteye.com/blog/2364084
今日推荐