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):
But the Scrollable function is not being applied to the Ajax loaded data, for example:
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?
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);
});
But the Scrollable function is not being applied to the Ajax loaded data, for example:
$(".scrollable").scrollable({ next: ".next", prev: ".prev" }).navigator(".nav");
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?
a jsfiddle or test version online would help to understand your problem.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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/
http://api.jquery.com/live/
ASKER
WOW! ChrisStanyon's solution worked and it was so simple... THANK YOU!!
ASKER
Note: It was the solution to add the Scrollable function call within the Ajax $.get function.