How to add Lytebox with AJAX contents ??


1 Votes, Rating: 51 Star2 Stars3 Stars4 Stars5 Stars

Tags: ,

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

Share/Save/Bookmark

3 Responses to “How to add Lytebox with AJAX contents ??”

  1. roshan says:

    was very helpful thanks a lot

  2. Heshan Peiris says:

    Thanks. :)

  3. CACA-COBRA says:

    NIIIIIIIIIIIIIIIIIIIICEEEEE!!!!!!!

Leave a Reply


CSS (Design) - TOP.ORG