Title: Custom Widget &#8211; Pass settings to javascript handler
Last modified: September 7, 2020

---

# Custom Widget – Pass settings to javascript handler

 *  [Ameer Mousavi](https://wordpress.org/support/users/amir-mousavi/)
 * (@amir-mousavi)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/custom-widget-pass-settings-to-javascript-handler/)
 * 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.

 * ![](https://ps.w.org/elementor/assets/icon-256x256.gif?rev=3444228)
 * [Elementor Website Builder - more than just a page builder](https://wordpress.org/plugins/elementor/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/elementor/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/elementor/)
 * [Active Topics](https://wordpress.org/support/plugin/elementor/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/elementor/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/elementor/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [Ameer Mousavi](https://wordpress.org/support/users/amir-mousavi/)
 * Last activity: [5 years, 9 months ago](https://wordpress.org/support/topic/custom-widget-pass-settings-to-javascript-handler/)
 * Status: not resolved