1

Whenever I try to initiate the widget from javascript things go haywire. The widget gets created but the whole content on page get overwritten (jsfiddle below). Any clue as what might solve this problem (using similar approach of initiating from javascript without iframes)?

var s2 = document.createElement("script");
s2.text = "new TradingView.widget({" +
   '"width": 450,' +
   '"height": 400,' +
   '"symbol": "SSD",' +
   '"interval": "D",' +
   '"timezone": "Etc/UTC",' +
   '"theme": "White",' +
   '"style": "1",' +
   '"locale": "en",' +
   '"toolbar_bg": "#f1f3f6",' +
   '"hide_side_toolbar": true,' +
   '"allow_symbol_change": true,' +
   '"hideideas": true' +
   '});'

  $(s2).appendTo("#feed");

You can see issue here: https://jsfiddle.net/g7tjaqg1/

I checked similar questions TradingView widget replacing entire HTML body but the solution utilizes iframes. Is it the only possible solution for this case?

ibininja
  • 1,209
  • 1
  • 15
  • 29

1 Answers1

1

You have to use the property container_id : "feed" which will load charts in specific container

Naveen Margan
  • 58
  • 1
  • 9