开发者

jquery boxy plugin: prevent multiple instances of the same dialog when clicking the link multiple times

I'm using the Boxy jQuery plugin to open dialog windows and populating it through ajax. http://onehackoranother.com/projects/jquery/boxy/

Here's my code so far:

$("a.create").click(function (e) {
  url = $(e.target).attr('href');
  Boxy.load(url, {title:'Test'});
});

This o开发者_如何学Cpens up a dialog alright. However, if I click the link again, another dialog will open. How can I make it such that the previously opened Boxy dialog will come into focus? I only want one instance of this dialog.

I tried assigning a variable to var ele = Boxy.load(); but the variable ele returns undefined... Alas, I can't make out much from the limited Boxy documentation available.

Enabling the option modal: true would prevent the user from clicking on the link multiple times, but I don't want the overlay to show.

Thanks for any light you can shed on this.

-Lyon


I decided to use a variable to identify if the boxy dialog has been opened. If it has, do nothing. Not an elegant solution though...

var dialog = false;
$("a.create").click(function () {
  if (!dialog) {
    dialog = new Boxy.load(this.href, {
      title: 'Test',
      afterHide: function() { dialog = null; },
    });
    return false;
  }
});


Just edit Boxy's CSS file to take away the overlay.

.boxy-modal-blackout { position: absolute; background-color: none; left: 0; top: 0;}


I wonder if the instance is visible

var winactive= $('#'+targetDiv).is(':visible'); 
//verificamos si el frame de carga es visible, esto indicara si la ventana modal esta activa        
if(winactive== false)
{
    //ok
     }
     else{// not}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜