Tony
Tony

Reputation: 12695

jQUery dialog hide effect repeat?

I load dynamically a page which contains that dialog declaration:

$("#promo-code-modal").dialog({
    modal: true,
    autoOpen: false,
    minHeight: 500,
    minWidth: 500,
    maxHeight:500,
    maxWidth:500,
    resizable: false,
    show: { 
        effect:"scale",
        speed:1000
    },
    hide: { 
        effect:"scale",
        speed:1000
    }
});

If I load that page for the second time (or more), during the close event, I see two times (or more) the scale effect in hide function. Why ?

Upvotes: 1

Views: 130

Answers (1)

Eduardo Quintana
Eduardo Quintana

Reputation: 2388

Maybe you are creating one dialog each time you reload your page try something like:

$("#promo-code-modal").clone().dialog({
    modal: true,
    autoOpen: false,
    minHeight: 500,
    minWidth: 500,
    maxHeight:500,
    maxWidth:500,
    resizable: false,
    show: { 
    effect:"scale",
    speed:1000
    },
    hide: { 
    effect:"scale",
    speed:1000
    },
    close: function(){
    $(this).dialog('destroy').remove();
    }
});

Hope it works for you.

Upvotes: 3

Related Questions