Javascript block within partial not executed after partial gets rendered -- Rails 3
When rendering partials, are Javascript blocks within a partial supposed to get executed?
For instance, assume inside "_partial_exmaple.html.erb" is a call to alert().
When I render this partial inside a view, will this alert get invoked?
If so, I'm doing something wrong as the Javascript blocks contained inside a partial are not getting executed.
Inside "viewA.html.erb":
<%= render :partial => 'partialA' %>
Inside "_partialA.html.erb":
<script type="text/javascript">
alert('hi');
</scrip开发者_开发百科t>
The alert function to display "hi" is not getting executed.
It sounds like you have a JavaScript error somewhere before this line of code, which is halting all JavaScript execution. Use your browser's JavaScript console to check for any errors.
In Chrome: View -> Developer -> JavaScript Console
精彩评论