gristmill / jquery-popbox

jQuery PopBox UI Element
http://gristmill.github.com/jquery-popbox/
420 stars 77 forks source link

Multiple popboxes per page #8

Open hvck opened 11 years ago

hvck commented 11 years ago

If you look at the original popboxes at Highrise they are pretty much modal, in the sense that if there are multiple instances on a page and you click one to open its dialog and then click another the first dialog closes and the second one opens.

With this plugin if you click on multiple links the dialogs all remain open. If they are near each other then there is overlap.

I'm not good enough at jquery or javascript to offer any suggestions on how to fix this, but I have a feeling it shouldn't be too hard.

hvck commented 11 years ago

Maybe I figured it out on my own:

I added $(".box").css({"display": "none"});

in the open function and it seems to work correctly.

clochette commented 11 years ago

In order to allow only one popbox opened at a time (if one is already open, clicking to open another one will close the first one) you just need to add methods.close(); in the script like this (4th line) :

if(box.css('display') == 'block'){ methods.close(); } else { methods.close();
box.css({'display': 'block', 'top': 10, 'left': ((pop.parent().width()/2) -box.width()/2 )}); } },

BeatnikDude commented 11 years ago

https://github.com/gristmill/jquery-popbox/issues/8#issuecomment-16193736 works thanks