Using Rails trying to pass in a JSON string from view to JS
Using Rails trying to pass in a JSON string from view to JS
I was playing around with child rows and have been using a hardcoded json string in my data table
$(document).ready(function() {
var table = $('#queryone_table').DataTable( {
"ajax": "/objects.txt",
I now want to switch to my real code. I have a controller that goes out to mongo and returns a json string, My view has that variable @mongoReturn I am unsure how to pass in that json string from my view to my javascript file that has my datatable definition.
Here is what I tried
My View
<
table class='table table-striped table-bordered table-hover table-condensed' id='queryone_table' data-source=<%= @mongoReturn %>)>
My JS
$(document).ready(function() {
var table = $('#queryone_table').DataTable( {
bServerSide: true,
sAjaxSource: $('#mongoReturn').data('source'),
"columns": [
Answers
What does your JSON return look like?
Does your server-side script actually implement server-side processing? Note also that since you use sAjaxSource it will be sending the legacy parameters.
Allan