<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="chrome=1" />
<script src="http://cdn.bootcss.com/jquery/1.12.3/jquery.min.js"></script>
</head>
<body>
<button class="layui-btn demo1">测试1</button>
<button class="layui-btn demo2">测试2</button>
<script>
var my = {
defaults: {
id: ".fast_pay",
client_id: '', //连接ID
sign:"",//签名
qr_load:null,
success: null // 支付成功后调用
},
set: function(options) {
var that = this;
that.settings = $.extend({}, that.defaults, options);
return that;
},
int: function(options) {
var that = this;
var that = this.set(options);
settings=that.settings;
$(document).on("click", settings.id, function() {
that.shows_qr($(this));
});
},
shows_qr: function(item) {
var that = this;
if (typeof settings.success === 'function') {
settings.success(item);
return false;
}
}
}
my.int({
id:".demo1",
success:function(data){
alert("demo1");
console.log("我是demo1的回调"+data);
}
});
my.int({
id:".demo2",
success: function(data) {
alert("demo2");
console.log("我是demo2的回调"+data);
}
});
</script>
</body>
</html>
为什么老是回调到 demo2!!
这种写法应该怎么去写???
点击按钮..进行回调!