iruby icon indicating copy to clipboard operation
iruby copied to clipboard

How to write Javascript function for iruby

Open Shekharrajak opened this issue 7 years ago • 3 comments

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 ?

Shekharrajak avatar Jul 12 '17 12:07 Shekharrajak

The error I see is this :

Javascript error adding output!
TypeError: $(...).DataTable is not a function
See your browser Javascript console for more details.

Shekharrajak avatar Jul 12 '17 12:07 Shekharrajak

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 .

Shekharrajak avatar Jul 13 '17 04:07 Shekharrajak

@mrkn ping!

v0dro avatar Jul 26 '17 06:07 v0dro