Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 4th, 2012  |  syntax: None  |  size: 1.39 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. unescaping javascript in rails .rb file / returning js in ruby methods
  2. %Q{<script type="text/javascript">
  3.     $(function() {
  4.         $('#{table_dom_id}').dataTable({
  5.           "oLanguage": {
  6.             "sSearch": "#{search_label}",
  7.             #{"'sZeroRecords': '#{no_records_message}'," if no_records_message}
  8.             "sProcessing": '#{processing}'
  9.           },
  10.           "sPaginationType": "full_numbers",
  11.           "iDisplayLength": #{per_page},
  12.           "bProcessing": true,
  13.           "bServerSide": #{server_side},
  14.           "bLengthChange": false,
  15.           "bStateSave": #{persist_state},
  16.           "bFilter": #{search},
  17.           "bAutoWidth": #{auto_width},
  18.           #{"'aaSorting': [#{sort_by}]," if sort_by}
  19.           #{"'sAjaxSource': '#{ajax_source}'," if ajax_source}
  20.           "aoColumns": [
  21.                 #{formatted_columns(columns)}
  22.                     ],
  23.             #{"'fnRowCallback': function( nRow, aData, iDisplayIndex ) { #{row_callback} }," if row_callback}
  24.           "fnServerData": function ( sSource, aoData, fnCallback ) {
  25.             aoData.push( #{additional_data_string} );
  26.             $.getJSON( sSource, aoData, function (json) {
  27.                     fnCallback(json);
  28.                 } );
  29.           }
  30.         })#{append};
  31.     });
  32.     </script>}
  33.        
  34. # Provided that my_escaped_string is what you want to display
  35. <%= my_escaped_string.html_safe %>
  36. <%= raw my_escaped_string %>