Aquí es mi genérica colorbox-apertura-función:
Se puede:
- Actualizar la página después de cerrar
- recargarlo-auto (+ con alguna URL Ajax personalizado)
- Cargue otro HTML
- IMPORTANTE -> estas acciones ocurren cuando cierra MANUALMENTE el colorbox:
- Configurar variables globales apropiadamente
- $ .colorbox.close();
también:
- Focus un elemento HTML personalizada después de la carga
El punto principal es, usted debe tener (pero, por supuesto, si usted sabe lo que está haciendo) algunas variables de JavaScript GLOBAL y eso es todo.
function showActionForColorBox(
_url,
_forFocus
) {
_url = fixURLWithMasterServerPrefix(_url);
$.colorbox(
{
scrolling: false,
href: _url,
onLoad: function() {
idColorboxAjaxIndect1.appendTo($('#cboxOverlay'));
idColorboxAjaxIndect2.appendTo($('#cboxOverlay'));
idColorboxAjaxIndect3.appendTo($('#cboxOverlay'));
idColorboxAjaxIndect4.appendTo($('#cboxOverlay'));
return;
},
onComplete: function() {
if (_forFocus) {
var c = $('#' + _forFocus);
if (c.length) {
c.focus();
}
}
return;
},
onCleanup: function() {
// TODO: ?
return;
},
onClosed: function() {
abortAllAsyncAjaxRequests();
if (shouldReloadPageAfterColorBoxAction) {
shouldReloadPageAfterColorBoxAction = false; // NOTE: To be sure: Reset.
reloadWholePage();
}
else if (cbEBillsActionReloadPopup) {
cbEBillsActionReloadPopup = false;
// NOTE: WE HAVE AN OPTION TO RELOAD COLORBOX WITH CUSTOM URL !
showActionForColorBox((cbActionReloadPopupCustomURL !== '' ? cbActionReloadPopupCustomURL : _url));
cbActionReloadPopupCustomURL = '';
}
else if (cbShouldLoadAnotherContentAfterClosed) {
cbShouldLoadAnotherContentAfterClosed = false;
$.colorbox({ html: setupContentForcbShouldLoadAnotherContentAfterClosed });
setupContentForcbShouldLoadAnotherContentAfterClosed = '';
}
return;
}
}
);
return;
}
No se olvide de aceptar la respuesta. –