请问这是什么问题,是事件冒泡造成的吗?
//添加jQuery模块依赖
require.config({//require自带config方法可以把文件名和映射的模块名相关联
paths:{jquery:'jquery.min',
jqueryUI:'jquery-ui.min'
}
});
require(['jquery','window'],function($,w){
$("#a").click(function(){
var win=new w.Window().alert({
title:"提示",
content:"welcome!",
handler:function(){
alert("You click the button");
},
width:300,
height:150,
y:50,
hasCloseBtn:true,
text4AlertBtn:"OK",
dragHandle:".window_header",
skinClassName:"window_skin_a",
handler4AlertBtn:function(){
alert("you click the alert button");
},
handler4CloseBtn:function(){
alert("you click the close button");
}
}).on("alert",function(){
alert("the second alert handler");
}).on("close",function(){
alert("the second close handler");
});
win.on("alert",function(){
alert("the third alert handler");
});
});
});
如上述代码琐示,除了自己加了皮肤skinClassName这个参数外其余和老师一模一样
问题出现在:
handler4AlertBtn:function(){
alert("you click the alert button");
},
handler4CloseBtn:function(){
alert("you click the close button");
}
当点击alert(OK按钮)时,出现了:you click the alert button ,you click the alert button,the second alert handler,the third alert handler看似和老师的一样但是明显的是you click the alert button多出现了1次,同样当点击关闭(close)按钮时也出现了:you click the close button,you click the close button,the second close handler即多出现了一次you click the close button,请问是什么原因?