Display 2 jcarousel loading from 2 different txt files

View: New views
5 Messages — Rating Filter:   Alert me  

Display 2 jcarousel loading from 2 different txt files

by Maxart! :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all!

I'd like to have 2 carousels loading content from 2 different files displayed on a single page, just like in the example "dynamic_ajax.html" (which loads dynamically the data from a simple text file which contains the image urls).

The part with the 2 carousels is ok (found in the forum):

jQuery(document).ready(function() {
    jQuery('#mycarousel1').jcarousel({
        itemLoadCallback: mycarousel_itemLoadCallback
    });
        jQuery('#mycarousel2').jcarousel({
        itemLoadCallback2: mycarousel_itemLoadCallback
    });
});

But how do I make "mycarousel1" load "carousel-content1.txt" and "mycarousel2" load "carousel-content2.txt"??

Thanks A LOT for the answer!

Regards,
Max

Re: Display 2 jcarousel loading from 2 different txt files

by jsor :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

Maxart! wrote:
Hi all!

I'd like to have 2 carousels loading content from 2 different files displayed on a single page, just like in the example "dynamic_ajax.html" (which loads dynamically the data from a simple text file which contains the image urls).

The part with the 2 carousels is ok (found in the forum):

jQuery(document).ready(function() {
    jQuery('#mycarousel1').jcarousel({
        itemLoadCallback: mycarousel_itemLoadCallback
    });
        jQuery('#mycarousel2').jcarousel({
        itemLoadCallback2: mycarousel_itemLoadCallback
    });
});

But how do I make "mycarousel1" load "carousel-content1.txt" and "mycarousel2" load "carousel-content2.txt"??

Thanks A LOT for the answer!

Regards,
Max
this has been answered here:
http://www.nabble.com/Dynamic-Load-Ajax-of-2-jcarousel-same-page-tf4202780.html#a11961838

Jan

Re: Display 2 jcarousel loading from 2 different txt files

by Maxart! :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks!

But it seems don't want to work: I have no more carousel on the page. Here is what I have now:

<script type="text/javascript">
function mycarousel_itemLoadCallback(url, carousel, state)
{
    if (state != 'init')
        return;

    jQuery.get(url, function(data) {
        mycarousel_itemAddCallback(carousel, carousel.first, carousel.last, data);
    });
};

function mycarousel_itemAddCallback(carousel, first, last, data)
{
    var items = data.split('|');

    for (i = 0; i < items.length; i++) {
        carousel.add(i+1, mycarousel_getItemHTML(items[i]));
    }

    carousel.size(items.length);
};

function mycarousel_getItemHTML(url)
{
    return '';
};

jQuery('#mycarousel1').jcarousel({
    itemLoadCallback: function (carousel, state) { mycarousel_itemLoadCallback('carousel-content1.txt', carousel, state); }
});

jQuery('#mycarousel2').jcarousel({
    itemLoadCallback: function (carousel, state) { mycarousel_itemLoadCallback('carousel-content2.txt', carousel, state); }
});
</script>

Thanks for the help.
Max

Jan Sorgalla wrote:
Hi,

Maxart! wrote:
Hi all!

I'd like to have 2 carousels loading content from 2 different files displayed on a single page, just like in the example "dynamic_ajax.html" (which loads dynamically the data from a simple text file which contains the image urls).

The part with the 2 carousels is ok (found in the forum):

jQuery(document).ready(function() {
    jQuery('#mycarousel1').jcarousel({
        itemLoadCallback: mycarousel_itemLoadCallback
    });
        jQuery('#mycarousel2').jcarousel({
        itemLoadCallback2: mycarousel_itemLoadCallback
    });
});

But how do I make "mycarousel1" load "carousel-content1.txt" and "mycarousel2" load "carousel-content2.txt"??

Thanks A LOT for the answer!

Regards,
Max
this has been answered here:
http://www.nabble.com/Dynamic-Load-Ajax-of-2-jcarousel-same-page-tf4202780.html#a11961838

Jan

Re: Display 2 jcarousel loading from 2 different txt files

by jsor :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

you have to put the carousel initialisation inside jQuery(document).ready() :

jQuery(document).ready(function() {
  jQuery('#mycarousel1').jcarousel({
      itemLoadCallback: function (carousel, state) { mycarousel_itemLoadCallback('carousel-content1.txt', carousel, state); }
  });

  jQuery('#mycarousel2').jcarousel({
      itemLoadCallback: function (carousel, state) { mycarousel_itemLoadCallback('carousel-content2.txt', carousel, state); }
  });
});

Thanks!

But it seems don't want to work: I have no more carousel on the page. Here is what I have now:

<script type="text/javascript">
function mycarousel_itemLoadCallback(url, carousel, state)
{
    if (state != 'init')
        return;

    jQuery.get(url, function(data) {
        mycarousel_itemAddCallback(carousel, carousel.first, carousel.last, data);
    });
};

function mycarousel_itemAddCallback(carousel, first, last, data)
{
    var items = data.split('|');

    for (i = 0; i < items.length; i++) {
        carousel.add(i+1, mycarousel_getItemHTML(items[i]));
    }

    carousel.size(items.length);
};

function mycarousel_getItemHTML(url)
{
    return '';
};

jQuery('#mycarousel1').jcarousel({
    itemLoadCallback: function (carousel, state) { mycarousel_itemLoadCallback('carousel-content1.txt', carousel, state); }
});

jQuery('#mycarousel2').jcarousel({
    itemLoadCallback: function (carousel, state) { mycarousel_itemLoadCallback('carousel-content2.txt', carousel, state); }
});
</script>

Thanks for the help.
Max

Jan Sorgalla wrote:
Hi,

Maxart! wrote:
Hi all!

I'd like to have 2 carousels loading content from 2 different files displayed on a single page, just like in the example "dynamic_ajax.html" (which loads dynamically the data from a simple text file which contains the image urls).

The part with the 2 carousels is ok (found in the forum):

jQuery(document).ready(function() {
    jQuery('#mycarousel1').jcarousel({
        itemLoadCallback: mycarousel_itemLoadCallback
    });
        jQuery('#mycarousel2').jcarousel({
        itemLoadCallback2: mycarousel_itemLoadCallback
    });
});

But how do I make "mycarousel1" load "carousel-content1.txt" and "mycarousel2" load "carousel-content2.txt"??

Thanks A LOT for the answer!

Regards,
Max
this has been answered here:
http://www.nabble.com/Dynamic-Load-Ajax-of-2-jcarousel-same-page-tf4202780.html#a11961838

Jan


Re: Display 2 jcarousel loading from 2 different txt files

by Maxart! :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

It works well now!
Thanks a lot (really)!

Cheers,
Max


Hi,

you have to put the carousel initialisation inside jQuery(document).ready() :

jQuery(document).ready(function() {
  jQuery('#mycarousel1').jcarousel({
      itemLoadCallback: function (carousel, state) { mycarousel_itemLoadCallback('carousel-content1.txt', carousel, state); }
  });

  jQuery('#mycarousel2').jcarousel({
      itemLoadCallback: function (carousel, state) { mycarousel_itemLoadCallback('carousel-content2.txt', carousel, state); }
  });
});
Maxart! wrote:
Thanks!

But it seems don't want to work: I have no more carousel on the page. Here is what I have now:

<script type="text/javascript">
function mycarousel_itemLoadCallback(url, carousel, state)
{
    if (state != 'init')
        return;

    jQuery.get(url, function(data) {
        mycarousel_itemAddCallback(carousel, carousel.first, carousel.last, data);
    });
};

function mycarousel_itemAddCallback(carousel, first, last, data)
{
    var items = data.split('|');

    for (i = 0; i < items.length; i++) {
        carousel.add(i+1, mycarousel_getItemHTML(items[i]));
    }

    carousel.size(items.length);
};

function mycarousel_getItemHTML(url)
{
    return '';
};

jQuery('#mycarousel1').jcarousel({
    itemLoadCallback: function (carousel, state) { mycarousel_itemLoadCallback('carousel-content1.txt', carousel, state); }
});

jQuery('#mycarousel2').jcarousel({
    itemLoadCallback: function (carousel, state) { mycarousel_itemLoadCallback('carousel-content2.txt', carousel, state); }
});
</script>

Thanks for the help.
Max

Jan Sorgalla wrote:
Hi,

Maxart! wrote:
Hi all!

I'd like to have 2 carousels loading content from 2 different files displayed on a single page, just like in the example "dynamic_ajax.html" (which loads dynamically the data from a simple text file which contains the image urls).

The part with the 2 carousels is ok (found in the forum):

jQuery(document).ready(function() {
    jQuery('#mycarousel1').jcarousel({
        itemLoadCallback: mycarousel_itemLoadCallback
    });
        jQuery('#mycarousel2').jcarousel({
        itemLoadCallback2: mycarousel_itemLoadCallback
    });
});

But how do I make "mycarousel1" load "carousel-content1.txt" and "mycarousel2" load "carousel-content2.txt"??

Thanks A LOT for the answer!

Regards,
Max
this has been answered here:
http://www.nabble.com/Dynamic-Load-Ajax-of-2-jcarousel-same-page-tf4202780.html#a11961838

Jan