Function not performed during javascript

Asked 2 years ago, Updated 2 years ago, 97 views

I'm developing it at Ruby on Rails.
The view is created with a slim, and I am thinking of applying the design of the AdminLTE table.
Among them is a javascript code for paging, etc.
It doesn't work.
The code for javascript is as follows.

<script>
  $(function(){
    $("#example1").DataTable();
  });
</script>

This is my slim code.

javascript:
  alert('Slim supports embedded javascript!11')
  $(function(){
    alert('Slim supports embedded javascript!22')
  $("#example1").DataTable();
});

I added an alert to my code to verify the operation of javascript.
There are two alerts, but they run where ~11 is present, but
It is not running where ~22 is written.
"Also, there was no particular difference in the html code in ""Page Source Display"" from the page I ran once."
So there seems to be no problem with slimming...
How can I execute that code?

javascript ruby-on-rails slim

2022-09-30 17:39

1 Answers

Is there an error because there is no semicolon between statements?

 alert('Slim supports embedded javascript!11');
$(function(){
    alert('Slim supports embedded javascript!22');
    $("#example1").DataTable();
});


2022-09-30 17:39

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.