I have a very long operation that ends in a huge array. That array is passed as a Ruby object to a js.erb file which renders a partial using it:
$('#xxx').html("<%= escape_javascript(render('part', testVar: @fromServer)) %>");
This all goes well, but I'd like to be able to sort columns in the resulting table without having to re-do the entire operation. It should be easy, but I can't get the resulting variable in the partial to persist. My goal is to be able to have a script tag in the partial:
<script type="text/javascript">
$("#column").click(function(){
$.ajax({
type : 'POST',
url : '/sort_column',
data : {data: jsVar},
dataType : 'script'
});
});
</script>
How would I go about doing this?