jquery - Change ruby variable in javascript -


this jquery obtain id in dropdown.

    $(document).ready(function(){         $('#installationsdropdown1 li a').on('click', function(){             id = $(this).html();         });     });  </script>      <div class="ibox-content graph">       <%= high_chart('main-graph', @highcharts[id]) %>     </div> 

how can pass dynamic variable id ruby code in view?

you cannot pass variables javascript code ruby code.

if understood correctly, have 2 choices:

make ajax call when user clicks on link. call render "high_chart" method in div. you'll have create action, , js.erb view. :

$("ibox-content.graph").html("<%= high_chart('main-graph', @highchart) %>"); 

your @highchart variable instantiated in controller using parameter send ajax call (your id instance).

another method preload charts in ruby when page loaded. manage in js 1 want show.


Comments

Popular posts from this blog

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -