Gazi Gazi - 2 years ago 90
jQuery Question

Redux Framework - multi select with commas

I created a slider in wordpress and for ther transition effects I have used the select field of the redux framework.

enter image description here

I checked the article here

but Im not sure why is not working.
below is the field that I have created in redux config

'id' => 'slide-transition',
'type' => 'select',
'multi' => true,
'title' => __('Slide Transition Effects', 'gazi'),
'subtitle' => __('Choose the transition effects for the slides, you can also use all effects together.', 'gazi'),
'options' => array('slide' => __('Slide','gazi'), 'elastic' => __('Elastic','gazi'), 'fade' => __('Fade','gazi'), 'blocks' => __('Blocks','gazi')), //Must provide key => value pairs for select options
'default' => array('slide','elastic','fade','blocks')


global $gazment;
$slide_transition = isset( $gazment['slide-transition'] ) ? $gazment['slide-transition'] : null;
if( !is_array( $slide_transition ) ){
$slide_transition = (array)$slide_transition;

and the out put in javascriptis:

transition:"<?php echo $slide_transition; ?>",
textformat: {

but it doesnt work because when i see the page source its something like this
I dont know what Im doing wrong, I need to get the selected elements with commas like:
how can I fix this?

any help will be very appreciated

Answer Source

I have resolved using in array like the code below

transition:"<?php if (in_array('slide', $slide_transition)) { echo 'slide,'; } if (in_array('elastic', $slide_transition)) { echo 'elastic,'; } if (in_array('fade', $slide_transition)) { echo 'fade,'; } if (in_array('blocks', $slide_transition)) { echo 'blocks,'; } ?>", scalemode:"fill",isfullscreen:false, textformat: {}

thanks to :)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download