Bloquear la interfaz de usuario al cargar la página

i want to block my ui until values in my drop down not loaded my js file code is as follows

$(document).ready(function() {
    // Load All Toll Plazas
    FillInCascadeDropdown({ userType: -1 }, "#ddlTollPlazas", "/Home/GetTollPlazas/" + -1);
}

function FillInCascadeDropdown(map, dropdown, action) {
    $(dropdown).empty();
    $.blockUI({ message: '<img src="/Content/images/ajax-loader.gif"/>' });
    $.post(action, map, function(data) {
        $.each(data, function() {
            $(dropdown).append("<option value=" + this.Value + ">" + this.Text + "</option>");
        });
    }, "json");
    $.unblockUI();
}

above code not working on page load.

preguntado el 02 de febrero de 12 a las 10:02

What exactly isn't working. Does it seem to block very quickly then go away? -

yes block very quickly and then go away -

1 Respuestas

I think you're problem is you are unblocking as soon as you call blockUI. You need to move the unblock call to a "Success" callback function. The concept of Callbacks are a little tricky. Basically this is the code that runs once the post is successful. I'm sure you've seen this page but refer to the jQuery post page to see where you need to put your callback and aquí to learn more about callbacks if you need to. Good luck!

Así es como debería verse:

function FillInCascadeDropdown(map, dropdown, action) {
    $(dropdown).empty();
    $.blockUI({ message: '<img src="/Content/images/ajax-loader.gif"/>' });
    $.post(action, map, function(data) {
        $.each(data, function() {
            $(dropdown).append("<option value=" + this.Value + ">" + this.Text + "</option>");
        });

        $.unblockUI();
    }, "json");

Respondido 02 Feb 12, 15:02

could you suggest me to where i can write unblockui() in above code - d.Siva

i wrote the same not working on page load means ui blocks and then unblocks immediately - d.Siva

Strange. So you only have 1 call to unblockUI() on the whole page? - CalamarScareMe

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.