Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3668592
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:08:28+00:00 2026-05-19T02:08:28+00:00

I am attempting to use jcarousel in conjunction with templates. When the images are

  • 0

I am attempting to use jcarousel in conjunction with templates. When the images are directly in the page the carousel it works perfectly, but I’m trying to make the images dynamic (not knowing which ones will load when the page loads) by using templates.

Here’s what I do, I have this jQuery code to load a template (external template)

var images = {
    imageItems: [
        { path: '../Content/img/strip/strip_1.jpg', name: 'Photo' },
        { path: '../Content/img/strip/strip_2.jpg', name: 'Photo' },
        { path: '../Content/img/strip/strip_3.jpg', name: 'Photo' },
        { path: '../Content/img/strip/strip_1.jpg', name: 'Photo' },
        { path: '../Content/img/strip/strip_2.jpg', name: 'Photo' },
        { path: '../Content/img/strip/strip_3.jpg', name: 'Photo' },
        { path: '../Content/img/strip/strip_1.jpg', name: 'Photo' },
        { path: '../Content/img/strip/strip_3.jpg', name: 'Photo' },
        { path: '../Content/img/strip/strip_2.jpg', name: 'Photo' },
        { path: '../Content/img/strip/strip_1.jpg', name: 'Photo' }
        ]
};

$.get('/jQueryTemplates/_photographerImagesSlideShow.tmpl.htm', function (templates) {
    $('body').append(templates);
    $('#imageSlideShowTemplate').tmpl(images).appendTo('.slidestrip');
});

This is the code from the external template

<script id="imageSlideShowTemplate" type="x-jquery-tmpl">    
    <ul id="slidestriplist" class="jcarousel-skin-tango">
        {{each imageItems}}
            <li>{{tmpl($value) '#slideShowImage'}}</li>
        {{/each}}
    </ul>
</script>

<script id="slideShowImage" type="x-jquery-tmpl">
    <a href="#" rel="lightbox"><img src="${path}" width="150" height="126" alt="${name}" /></a>
</script>

After I load the template I have this code to initialize the carousel, or at least that’s what it’s supposed to do

$('.slidestrip img').each(function () {
    $(this).hover(function () {
        $(this).stop().animate({ opacity: 1.0 }, 500);
    },
        function () {
            $(this).stop().animate({ opacity: 0.5 }, 500);
        });
});

$('#slidestriplist').jcarousel({
    visible: 6
});

Now the problem, the carousel isn’t working because, I assume, it’s trying to initialize it before the template is actually injected into the page, thus causing the images to load vertically and not horizontally and there is no carousel (even the hover of the images does nothing).

So here’s the question, does anyone know how I can get this working when using templates in this manner? How to only initialize the carousel after the template has been injected into the markup?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T02:08:28+00:00Added an answer on May 19, 2026 at 2:08 am

    A solution has been formulated for this issue, with the help of Dave Ward, so I thought I would share it with others, in case someone came along with the same (or similar issue). I needed to delay initializing jCarousel and to do this I needed to call jCarousel from within the $.get() call like this:

       $.get('/jQueryTemplates/_photographerImagesSlideShow.tmpl.htm', function (templates) {
            $('body').append(templates);
            $('#imageSlideShowTemplate').tmpl(images).appendTo('.slidestrip');
    
            //now load our carousel and add the hover affect to the images
            $('.slidestrip img').each(function () {
                $(this).hover(function () {
                    $(this).stop().animate({ opacity: 1.0 }, 500);
                },
                function () {
                    $(this).stop().animate({ opacity: 0.5 }, 500);
                });
            });
    
            $('#slidestriplist').jcarousel({
                visible: 6
            });
        });
    

    Thanks for your help on this one Dave

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When attempting to use HttpWebRequest to retrieve a page from my dev server, I
I'm attempting to use the rest-client gem to post something, but for some reason,
I'm attempting to use Python to convert a multi-page PDF into a series of
I'm attempting to use the new partial page caching available in ASP.NET MVC 3.
I'm attempting to use the Draw9Patch tool from the Android SDK, but immediately upon
I'm attempting to use the Google geocoder API to enter user's location information directly
Attempting to use the data series from this example no longer passes the JSONLint
Attempting to use XStream's JavaBeanConverter and running into an issue. Most likely I'm missng
Im attempting to use a C++ extension for Python called PySndObj. and getting an
In attempting to use std::select1st from <functional> in a VS2008 project I found that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.