PDA

View Full Version : Call a function from an opened div layer



guvenck
Mar 1st, 2007, 04:22 PM
Hello,

I am using GreyBox (http://orangoo.com/labs/GreyBox/) (which is a lightbox kind of popup window layer) on one of my sites.

On the site, somewhere I use Panels (div layers) that appear when
clicked on a link and give me options.

Keep it simple, this is how I call a panel (There is some PHP involved
but ignore it):


<a id="panel$ID" href="#" onClick="return Panel($ID, $title);">$title</a>

and my JS function is as follows:



function Panel(id,title) {
if (PanelLoaded[id]) {
closePanel(id);
return false;
}
PanelLoaded[id] = true;
contBoxid = 'panel'+id;
var contBox = document.getElementById(contBoxid);
box = document.createElement('div');
box.className = 'contbox';
box.id = 'contbox'+id;
box.style.cursor = 'default';
box.style.position = 'absolute';
box.style.marginTop = '5px';
box.style.marginLeft = '10px';
box.style.padding = '5px';
box.style.width = '280px';
box.style.textAlign = 'left';
box.style.backgroundColor = '#003366';
box.style.border = 'solid 1px #000000';
box.style.MozBorderRadius = '7px';

box.innerHTML = ''+
'<table class="table_panels" cellspacing="0">'+
'<tr>'+
'<td class="ptitle" colspan="3">'+title+'</td>'+
'</tr>'+
'<tr>'+
'<td><img src="images/panels/info.gif" alt="Info"></td>'+
'<td><a href="books.php?op=showbook&bid='+id+'"
onClick="closePanel('+id+');">Info</a></td>'+
'</tr>'+
'<tr>'+
'<td><img src="images/panels/list.gif" alt="List"></td>'+
'<td><a href="mylists.php?bid='+id+'" title="My Lists"
rel="gb_page_center[400, 300]" onClick="closePanel('+id+');">View
Lists</a></td>'+
'</tr>'+
'<tr>'+
'<td><img src="images/panels/comments.gif" alt="Make Comment"></td>'+
'<td><a href="books.php?op=showcomments&bid='+id+'&sel=2"
onclick="closePanel('+id+');">Comments</a></td>'+
'</tr>'+
'<tr>'+
'<td><img src="images/panels/close.gif" alt="Close Panel"></td>'+
'<td><a href="#" onClick="return closePanel(\''+id+'\')">Close</a></
td>'+
'</tr>'+
'</table>';

contBox.parentNode.appendChild(box);
return false;

}

function closePanel(id) {
boxid = 'contbox'+id;

document.getElementById(boxid).parentNode.removeChild(document.getElementById(boxid));
PanelLoaded[id] = false;
return false;

}


If you look at the Lists part - this is where call the GreyBox function with rel attribute.

If I load the page and click on the link, the Panel comes up and when
I click "View Lists", GreyBox does not come up, instead the browser
loads the page that GreyBox should have loaded.

So, how can I call the gb_page_center from this panel? I tried adding
parent and parent.parent before gb_page_center but it did not help.

Any help is highly appreciated.