iruby
iruby copied to clipboard
How to write Javascript function for iruby
I am trying to generate HTML and Javaascript code for the data table. When I use
<script type='text/javascript'>
$(document).ready(function() {
$('#id').DataTable(
{..}
);
});
</script>
then it works fine for the Web application . But it doesn't work for IRuby notebook.
The IRuby notebook I tried is this .
How can we replace $
, ready
so that it can work on both ?
The error I see is this :
Javascript error adding output!
TypeError: $(...).DataTable is not a function
See your browser Javascript console for more details.
Actually I want to replace JQuery code and write in Javascript only so that it can work . $( document ).ready()
will only run once the page Document Object Model (DOM) is ready for JavaScript code to execute.
I fixed the similar problem by removing the var onload = window.onload;
and replacing (function() {
with
$(function() { and ending it with
});not
})()` . The code is here .
@mrkn ping!