371 posts
  • Has referred 50+ members
  • Has sold $125,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+5 more
PixelStores says

Hi,

I’m using the wp_localize_script function to pass a few custom field values to my script and one of the values are numbers.

When i ‘alert’ the value in the jQuery, the output is correct however it does not correctly work within the necessary script area.. (an option for the caroufredsel plugin).

alert(car.test);
$('#slider_carousel').carouFredSel({
        prev: '.prevslide',
        next: '.nextslide',

        scroll        : {
            items            : car.test,
            fx                : car.carousel_transition,
            easing            : car.carousel_easing,
            duration        : car.carousel_duration,
            pauseOnHover    : car.carousel_pause,
            queue            : false,
            event            : "click",
            conditions        : null,
            onBefore        : null,
            onAfter            : null,
            onEnd            : null
        },
            circular : car.carousel_circular,
            infinite    : car.carousel_infinite,
        }, 
        {
            debug        : false,
            transition    : true,
            wrapper        : {
            element            : "div",
            classname        : "slide_carousel" 
        }
    });
});

The car.test does not work in the “carouFredSel” configuration.

The only way the output works if i use the following above the code:

if(car.test == 1) {car.test = 1;} else if (car.test == 2) {car.test = 2;} else if (car.test == 3) {car.test = 3;}

But that is surely not the appropriate way for this.

The wp_localize_script code must working alright as the alerts check seem to show the correct values.

Any input highly appreciated.

Cheers

438 posts
  • Has been part of the Envato Community for over 2 years
  • Has sold $5,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Located in Europe
+1 more
Pixelous says

Hi, you should use

parseInt( car.test )
.
371 posts
  • Has referred 50+ members
  • Has sold $125,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+5 more
PixelStores says

Hi, you should use
parseInt( car.test )
.

That simple! Thanks Pixelous all works great :)

by
by
by
by
by
by