I encapsulated a js function myself! There are some problems with using
. I set callback, to increase as the number of clicks increases, so does the number of execution. I don"t know why!
functions encapsulated by js
showConfirm(title , content , showCancel , success , cancel)
{
showCancel = showCancel === false ? showCancel : true;
$("-sharpshowModal .modal-title").text(title);
$("-sharpshowModal .modal-body").text(content);
if(!showCancel)
{
$("-sharpshowModal .cancel").hide();
}
$("-sharpshowModal .cancel").eq(0).click(cancel);//DOM
$("-sharpshowModal .success").eq(0).click(success);//DOM
$("-sharpshowModal").modal();
}
Front end call
<button class="btn btn-info btn-sm" onclick="test()">test</button>
<script>
function test()
{
pages.showConfirm("","",true,function(){
console.log(1);
},function(){
console.log(2);
})
}
</script>
the number of times printed in console.log will increase with the number of clicks!