• Hey there.
    I just created a custom widget for showing cryptocurrencies prices on a line chart.
    This widget has some controls like interval, cryptocurrency symbol and etc.
    Now I want to pass these controls settings to javascript handler of widget and build API url based on these settings.

    What is the best practice for this situation? I tried the below method:

    
    protected function render($instance = []) {
    		
    		$settings = $this->get_settings_for_display();
    		?>
    		<canvas id="chart-<?=$this->get_id()?>" data-widget-settings="<?=json_encode($settings)?>" ></canvas>
    		<?php
    	}
    

    but this outputs a lot of unneeded settings which is not seems to be good.

    Thank you in advance.

The topic ‘Custom Widget – Pass settings to javascript handler’ is closed to new replies.