How to add Lytebox with AJAX contents ??
Lytebox/Lightbox problem with AJAX ??
is there any way to add Lytebox/Lightbox within Ajax/jquery loaded pages ???
YES!, now you can add lytebox effect on Ajax loaded content too, It was really tough to search out how ?
but i have try a lot and find out a solution, and it works with any Ajax, jquery etc.
for know more about Lytebox please visit on this site
Solution
The problem was that Lytebox gets initialized during page load. Since AJAX bypasses page load, the problem arises.
The Lytebox run by this function initLytebox(); so we just need to call this functions when our ajax parsed data properly.
See Ajax example
Your code will probably look like this…
function handleHttpResponse() {
if (http.readyState == 4) {
document.getElementById(’ResultDiv’).innerHTML = http.responseText;
initLytebox(); //////////// call that function here
}
}
See Jquery example
 Your jquery code will probably look like this…
$.ajax({
type: “POST”,
url: ajax.php”,
data: dataString,
cache: false,
success: function(html){
 $(”#ajaxdata”).prepend(html);
Â
///// Lytebox
 initLytebox(); /// add there your lytebox function to work
}
});
Â
make sure you have added download js files on this page
enjoy









November 18th, 2009 at 7:20 am
was very helpful thanks a lot
December 3rd, 2009 at 10:11 am
Thanks.
February 1st, 2010 at 10:13 am
NIIIIIIIIIIIIIIIIIIIICEEEEE!!!!!!!