开发者

Javascript block within partial not executed after partial gets rendered -- Rails 3

开发者 https://www.devze.com 2023-03-16 16:59 出处:网络
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 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

0

精彩评论

暂无评论...
验证码 换一张
取 消