Link to home
Start Free TrialLog in
Avatar of intoxicated_curveball
intoxicated_curveball

asked on

Loaded ajax data not being recognized by jQuery Scrollable function

I'm using a simple jQuery "scrollable" function from the jQuery Tools library. I combined it with jQuery Ajax $.get function... so when you click certain links on the page it loads the HTML data for the respective Scrollable item.

Link to jQuery Scrollable demo

The Ajax is WORKING, when I click the item it loads in the Scrollable item (HTML data), for example (pulls the ID from the element ID):

function ajax(file){
    $.get(file,function(data) {
        $("#mydiv").html(data);
    });
}

$(".scrollindex").click(function() {
    var myid = $(this).attr("id");
    ajax('content.asp?i=' + reelId);
});

Open in new window


But the Scrollable function is not being applied to the Ajax loaded data, for example:

$(".scrollable").scrollable({ next: ".next", prev: ".prev" }).navigator(".nav"); 

Open in new window


The navigation elements which are created with the 'next', 'prev', and 'navigator' assignments are simply not working / not being created.

It works fine when I don't use the Ajax method.

Is there something I'm doing wrong? Is there a limitation of Ajax? Should I be using a different Ajax method here?
Avatar of mcnute
mcnute
Flag of Germany image

a jsfiddle or test version online would help to understand your problem.
ASKER CERTIFIED SOLUTION
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Look at .live or .on in jQuery.  It may be because the new content from AJAX is not recognized in the DOM.  live or on should resolve.

http://api.jquery.com/live/
Avatar of intoxicated_curveball
intoxicated_curveball

ASKER

WOW! ChrisStanyon's solution worked and it was so simple... THANK YOU!!
Note: It was the solution to add the Scrollable function call within the Ajax $.get function.