js,jq实现对话框,自己写的,该怎么解决
js,jq实现对话框,自己写的
我自己写了一个confirm和alert对话框...(我是学习弄的,不要让我去用什么easyui,或者他js本身的对话框)
下面是我自己的js
我注释掉那两句 是为了给 确定 取消绑定事件的。。。我恰恰就是不懂怎么弄这里
我想实现的是 在任何一个页面 只要调用
这个怎么实现啊
------解决思路----------------------
------解决思路----------------------
<div id='appAlert' class='confirm' name='confirm'>
<div class='title' name='title'></div>
<div class='body' name='body'></div>
<div class='bottom' >
<button name='btok'>OK</button> <button name='btcancel'>Cancel</button>
</div>
</div>
我自己写了一个confirm和alert对话框...(我是学习弄的,不要让我去用什么easyui,或者他js本身的对话框)
下面是我自己的js
var AppDaliog = {
confirm: function(msg, title,ok,cancle) {//ok 确定函数 cancle取消函数
if ($("#appAlert").length == 0) {
var html = new Array();
html.push("<div id='appAlert' class='dlgMain'><div class='dlgContext'><div class='dlgHead'>" + title + "</div>");
html.push("<div class='dlgShow'>" + msg + "</div><div class='dlgFoot'><a href='javascript::' class='button' id='ok_qxy_confirm'>确定</a>")
html.push("<a href='#' class='button' id='cancle_qxy_confirm'>取消</a> </div></div>");
// html.push("<script type='text/javascript'> $('#ok_qxy_confirm').click(function() {if (ok != undefined) {$('#appAlert').hide();ok();}else{ $('#appAlert').hide(); }});");
// html.push(" $('#cancle_qxy_confirm').click(function() {if (cancle != undefined) {$('#appAlert').hide();cancle();}else{ $('#appAlert').hide();} });</script>");
$('body').append(html.join(""));
$("#appAlert").show();
}
else {
$("#appAlert").show();
}
},
alert: function() { }
}
我注释掉那两句 是为了给 确定 取消绑定事件的。。。我恰恰就是不懂怎么弄这里
我想实现的是 在任何一个页面 只要调用
AppDaliog .confirm("msg","title",funtion(){
//对应上面的ok函数
},funtion(){
//对应上面的cancle函数
});
这个怎么实现啊
------解决思路----------------------
var AppDaliog = {
confirm: function(msg, title,ok,cancle) {//ok 确定函数 cancle取消函数
if ($().length == 0) {
var html = new Array();
html.push("<div id='appAlert' class='dlgMain'><div class='dlgContext'><div class='dlgHead'>" + title + "</div>");
html.push("<div class='dlgShow'>" + msg + "</div><div class='dlgFoot'><a href='javascript::' class='button' id='ok_qxy_confirm'>确定</a>")
html.push("<a href='#' class='button' id='cancle_qxy_confirm'>取消</a> </div></div>");
// html.push("<script type='text/javascript'> $('#ok_qxy_confirm').click(function() {if (ok != undefined) {$('#appAlert').hide();ok();}else{ $('#appAlert').hide(); }});");
// html.push(" $('#cancle_qxy_confirm').click(function() {if (cancle != undefined) {$('#appAlert').hide();cancle();}else{ $('#appAlert').hide();} });</script>");
var dddd=$(html.join(""));
dddd.find('#ok_qxy_confirm').click(ok);
dddd.find('#cancle_qxy_confirm').click(cancle);
$('body').append(dddd);
$("#appAlert").show();
}
else {
$("#appAlert").show();
}
},
alert: function() { }
}
------解决思路----------------------
<div id='appAlert' class='confirm' name='confirm'>
<div class='title' name='title'></div>
<div class='body' name='body'></div>
<div class='bottom' >
<button name='btok'>OK</button> <button name='btcancel'>Cancel</button>
</div>
</div>