Patrick Downey
Patrick Downey

Reputation: 965

When using prepOverlay, how can multiple overlays be prevented from opening?

I'm using Plone 4.3 and I have a browserview where I have links that open up an overlay of a specific form In my html, I have

<table>
    <thead>
        <tr>
            <th class='.prep_form'>Sun</th>
            <th class='.prep_form'>Mon</th>
            ...
        </tr>
    </thead>
    <tbody>
        ...
    </tbody>
</table>

in my jquery file

jquery(function($){
    ...
    $('.prep_form').prepOverlay({
        subtype: 'ajax',
        filter: '#content-core > form',
        noform: 'redirect',
        redirect: function(){
            redirect_location = ""; // put together a string
            return redirect_location;
        },
    });
    ...
});

Unfortunately, I can click the links multiple times before the form overlay opens, which leads to more than one opening.

How can I prevent more than one overlay from opening?

Upvotes: 1

Views: 144

Answers (1)

1letter
1letter

Reputation: 331

In the Docs of jquery tools is a option for Overlay:oneInstance:true But it should be the default value. You can close all open Overlays via this.getOverlay().close()

$('.prep_form').prepOverlay({
    subtype: 'ajax',
    filter: '#content-core > form',
    noform: 'redirect',
    redirect: function(){
        redirect_location = ""; // put together a string
        return redirect_location;
    },
    config: {
        oneInstance:true,
        onBeforeLoad : function (e) {
            console.log('onBeforeLoad', this.getOverlay());                
            this.getOverlay().close();
            return true;
        }
    }        
});

Upvotes: 2

Related Questions