javascript - Sweet Alert Yii -
i trying use sweet alert in yii in place on confirmation option.
i have ajax button , sweet alert pop up, once user has chosen confirm or cancel can either continue ajax request or stop.
'ajax' => array( 'url'=>ccontroller::createurl('items/delete'), 'type'=>'post', 'async'=>true, 'data'=>array('item'=>$item['item_id']), 'datatype'=>'json', 'enctype'=>'multipart/form-data', 'cache'=>false, 'beforesend'=>'js:function(data) { var x = sweetalertdelete(); if(x){alert("aaaaaaa"); return true;} else {alert("bbbbb"); return false;} }', 'success'=>'function(data) {
i using beforesend in order display sweet alert box. issue the box appears, x returned , alerts seen later shown. here sweet alert code:
function sweetalertdelete(){ swal({ title: "<?php echo yii::t('app','misc.order_delete'); ?>", text: "you not able recover imaginary file!", type: "warning", showcancelbutton: true, confirmbuttoncolor: "#dd6b55", confirmbuttontext: "yes, delete it!", closeonconfirm: false, closeoncancel: false }, function (isconfirm) { //swal("deleted!", "your imaginary file has been deleted.", "success"); if (isconfirm) { alert("true"); return true; } else { alert("false"); return false; } }); }
my question how can make value of isconfirm returned , until confirm/cancel button clicked, ajax request not sent.
Comments
Post a Comment