mercredi 5 août 2015

jquery ajaxStart call inside msgbox Success function


I am doing a File upload using a confirmation box with Ok and Cancel using MsgBox. The code is as follows.

$.msgBox({
    title : title,
    content : message,
    type : type,
    buttons: [{
        type: "submit", 
        value: "Ok"
    },{        
        type: "cancel", 
        value: "Cancel"
    }],
    success: function (result) {
        // alert(result);
        if (result == "Ok") {
            $(document).ajaxStart(function(){
                $.blockUI({ 
                    message: $('.box'), 
                    css: { 
                        padding: '20px', 
                        backgroundColor: '#fff', 
                        '-webkit-border-radius': '10px',
                        '-moz-border-radius': '10px',
                        opacity: .6, 
                        color: '#fff'    
                    }    
                }); 
            });
            $(document).ajaxStop($.unblockUI); 
        }

        $(document).ajaxForm({
            // My Upload Code 
        }
    }
});

So when I click Ok button I have to start ajax and block my UI. Its a file Upload So my file upload Progress will be loaded upto the ajax gets stopped.

Problem

When I click on upload A confirmation Box should come and when I click OK then the code sequence should go like ajaxStart should start and my file upload AJAXFORM should progress continue, when the AJAXFORM request stops unblockUI will activate.

Problem is that I am not able to give these sequential code inside success of the $.msgBox(). On one click it is not working, on the second click only the form is getting uploading. When the same set of code is used normally it is working Fine but not inside the success.

Is there any option to use ajaxForm,AjaxStart call inside success of another jquery plugin?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire