I'm preparing plugin and I have trouble to call (and return) javascript from each (same) shortcode in one wp page/post. Javascript returns values only to last shortcode in page.
PHP code here:
add_shortcode( 'ada_chart', 'ada_chart_stranka' );
function ada_chart_stranka ($atts) {
$a = shortcode_atts( array(
'cid' => '',
), $atts );
$cislo_chart = $a['cid'];
wp_register_script( 'ada_chart_handle', plugins_url().'/ada-chart/js/ada-chart1.js' );
$ada_sheet_params = array(
'ada_ch_cislo' => $cislo_chart,
);
wp_localize_script( 'ada_chart_handle', 'ada_ch', $ada_sheet_params );
wp_enqueue_script( 'ada_chart_handle');
return 'atribut: '.$cislo_chart;
}
and JS script here:
var cisloChart = ada_ch.ada_ch_cislo;
document.getElementById('chart_div'+cisloChart).innerHTML = 'Cislo: ' + cisloChart;
Can anybody hepl me? Thanks