RailsDatatables in rails 3
RailsDatatables in rails 3
datatabler
Posts: 1Questions: 0Answers: 0
Hello together
I need help to get the datatables plugin in rails 3 (http://github.com/phronos/rails_datatables) to work.
I inserted the code below as described on github.
<% columns = [{:type => 'html', :class => "first"}, {:type => 'html'}, {:type => 'html'}, {:type => nil, :class => "last"}] %>
<%= datatable(columns, {:sort_by => "[0, 'desc']", :processing => image_tag("spinner.gif") }) %>
The ruby code above produces the following html output:
[code]
$(function() {
$('.datatable').dataTable({
"oLanguage": {
"sSearch": "Search",
"sProcessing": ''
},
"sPaginationType": "full_numbers",
"iDisplayLength": 25,
"bProcessing": true,
"bServerSide": false,
"bLengthChange": false,
"bStateSave": true,
"bFilter": true,
"bAutoWidth": true,
'aaSorting': [[0, 'desc']],
"aoColumns": [
{
'sType': 'html',
'bSortable':true,
'bSearchable':true
,'sClass':'first'
},{
'sType': 'html',
'bSortable':true,
'bSearchable':true
},{
'sType': 'html',
'bSortable':true,
'bSearchable':true
},{
'sType': 'string',
'bSortable':true,
'bSearchable':true
,'sClass':'last'
}
],
"fnServerData": function ( sSource, aoData, fnCallback ) {
aoData.push( );
$.getJSON( sSource, aoData, function (json) {
fnCallback(json);
} );
}
});
});
[/code]
The table:
[code]
Name
Account Level
Email
<%- @users.each do |user| -%>
<%= user.last_name %>
<%= user.first_name %>
<%= user.email %>
<%- end -%>
[/code]
But this isn't working. What am I doing wrong? Do I have to place some code in the controller?
I included all necessary libaries. May be someone can give me an example working project?
Thank you very much!
I need help to get the datatables plugin in rails 3 (http://github.com/phronos/rails_datatables) to work.
I inserted the code below as described on github.
<% columns = [{:type => 'html', :class => "first"}, {:type => 'html'}, {:type => 'html'}, {:type => nil, :class => "last"}] %>
<%= datatable(columns, {:sort_by => "[0, 'desc']", :processing => image_tag("spinner.gif") }) %>
The ruby code above produces the following html output:
[code]
$(function() {
$('.datatable').dataTable({
"oLanguage": {
"sSearch": "Search",
"sProcessing": ''
},
"sPaginationType": "full_numbers",
"iDisplayLength": 25,
"bProcessing": true,
"bServerSide": false,
"bLengthChange": false,
"bStateSave": true,
"bFilter": true,
"bAutoWidth": true,
'aaSorting': [[0, 'desc']],
"aoColumns": [
{
'sType': 'html',
'bSortable':true,
'bSearchable':true
,'sClass':'first'
},{
'sType': 'html',
'bSortable':true,
'bSearchable':true
},{
'sType': 'html',
'bSortable':true,
'bSearchable':true
},{
'sType': 'string',
'bSortable':true,
'bSearchable':true
,'sClass':'last'
}
],
"fnServerData": function ( sSource, aoData, fnCallback ) {
aoData.push( );
$.getJSON( sSource, aoData, function (json) {
fnCallback(json);
} );
}
});
});
[/code]
The table:
[code]
Name
Account Level
<%- @users.each do |user| -%>
<%= user.last_name %>
<%= user.first_name %>
<%= user.email %>
<%- end -%>
[/code]
But this isn't working. What am I doing wrong? Do I have to place some code in the controller?
I included all necessary libaries. May be someone can give me an example working project?
Thank you very much!
This discussion has been closed.
Replies
<%= raw 'string' %>
http://stackoverflow.com/questions/4754438/unescaping-javascript-in-rails-rb-file-returning-js-in-ruby-methods