Hi,

why don't you use just two different loadItemHandler's?

Jan


dvp wrote:
> 
> Jan,
> 
> This seems to solve the multiple data sources on a single page problem,
> but I would appreciate your feeback.
> 
> First I added the datasrc property to the object:
> ==================================
> 
> var priv = {
>     o: {
>     datasrc: null,   // ADDED FOR MULTIPLE DATA SOURCES
>     orientation: "horizontal",
>     itemStart: 1,
>     itemVisible: 3,
>     itemScroll: null,
>     .....
> 
> =========================================
> Then, I set the variable in the "load:" method to be used by the
> loadItemHandler (see last param):
> =========================================
> 
> load: function(first, last) {
>     if (priv.o.loadItemHandler == null)
>         return priv.loaded();
> 
>      priv.buttons(false, false);
> 
>     /* ADDED THIS BLOCK SUPPORT MULTIPLE DATA SOURCES */
>     if (priv.o.datasrc){ 
>         var dsrc = priv.o.datasrc;
>     }else{
>         alert('No data source specified in contructor');
>         return;
>     }
>                               
>     priv.o.loadItemHandler(publ, first, last, priv.available(first, last),
> dsrc);
> },
> 
> 
> =========================================
> Then, I use the new param in the loadItemHandler as follows:
> =========================================
> 
> function loadItemHandler(carousel, start, last, available, dsrc){
>       if (!available) {
>         for (var i = start; i <= last; i++) {
>             if (i > dsrc.length) {
>                 break;
>             }
> 
>             carousel.add(i, getItemHTML(dsrc[i - 1]));
>         }
>     }
> 
> 
> =========================================
> Finally, I set the property in the constructor for each separate jCarousel
> and it seems to work fine.
> =========================================
> 
> // Ride the carousel...
> jQuery(document).ready(function() {
>     jQuery("#mycarousel1").jcarousel({
>       datasrc: itemList1,
>         itemVisible: 3,
>         itemScroll: 2
>     });
>     jQuery("#mycarousel2").jcarousel({
>       datasrc: itemList2,
>         itemVisible: 3,
>         itemScroll: 2
>     });
> });
> 
> 
> =========================================
> My biggest concern is the possibility of memory or performance issues by
> passing an object through the contructor.  Any feedback on this hack would
> be appreciated.
> Thanks,
> 
> Duncan
> 

-- 
View this message in context: 
http://www.nabble.com/Dynamically-loadiing-2-jCarousels-from-separate-data-sources-on-same-page-tf3079083.html#a8559652
Sent from the jCarousel mailing list archive at Nabble.com.


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to