Still no go. I now have this: <script type="text/javascript" charset="utf-8"> $(document).ready(function() { init_gallery(); function init_gallery() { $('.sliderGallery').each(function(){ var id_parts = $(this).attr('id').split('_'); var id = id_parts[id_parts.length - 1]; var container = $('#sliderGallery_' + id) ; var ul = $('ul', container); alert(id); var itemsWidth = ul.innerWidth() - container.outerWidth(); $('.slider', container).slider({ min: 0, max: itemsWidth, handle: '.handle', stop: function (event, ui) { ul.animate({'left' : ui.value * -1}, 500); }, slide: function (event, ui) { ul.css('left', ui.value * -1); } }); }); } }); </script>
Works if not loaded into a div, will not work if loaded into div, yet the alert(id); still shows in both cases. Ideas? Dave ________________________________ From: Cam Spiers [mailto:camspi...@gmail.com] Sent: September-07-09 8:07 PM To: jquery-en@googlegroups.com Subject: [jQuery] Re: live() help Hi I'm not exactly sure what you mean by "loaded into a div" but I assume that this script is being loaded into the document after the document/window is already ready. It is possible you need to remove the $(window).ready event. Maybe the bound ready functions have been triggered already and are not being triggered again. Regards, Cam On Tue, Sep 8, 2009 at 10:29 AM, Dave Maharaj :: WidePixels.com <d...@widepixels.com> wrote: I have this on a page that gets loaded into a div but its not working when loaded. I originally had the page load normally in the browser and it worked, only since loading it into the div has it stopped. Not sure if it has anything to do with it but i want to add .live() to the function and give it a try but no idea where to add it just to see if that does anything. Or does anyone have any ideas that might help me to get this working again. $(window).ready(function() { $('.sliderGallery').each(function(){ var id_parts = $(this).attr('id').split('_'); var id = id_parts[id_parts.length - 1]; var container = $('#sliderGallery_' + id) ; var ul = $('ul', container); var itemsWidth = ul.innerWidth() - container.outerWidth(); $('.slider', container).slider({ min: 0, max: itemsWidth, handle: '.handle', stop: function (event, ui) { ul.animate({'left' : ui.value * -1}, 500); }, slide: function (event, ui) { ul.css('left', ui.value * -1); } }); }); }); Thanks, Dave