lundi 7 mars 2016

Calling js function from erb file

I have an erb file that is creating a table. Something like this:

<td>Option 1</td>
<td>Option 2</td>

I have a javascript function called Foo() placed inside the application.js

Now I want the td header to show somehthing like this:

Option 1 Foo()

I tried doing it this way:

<td>Option 1 <script type="text/javascript">Foo()</script></td>

And it didn't work. Also tried this and it didn't work as well:

<td>Disbursement initiation date <%= javascript_tag "Foo()" %></td>

Any advice on how to do it?!

Aucun commentaire:

Enregistrer un commentaire