I need to call some javascript while rendering a partial in rails 3. like:
_my_partial.html.erb
Whenever this partial renders, a javascript function should be called.
Try this in _my_partial.html.erb
:
For html
:
# partial code
<script type="text/javascript">
your_function();
</script>
For haml
:
# partial code
:javascript
your_function(#{@variable});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.