Hi I am calling a partial from controller file but the javascript inside the partial is not executing . The partial is of .html.erb format.
<% content_for :javascript do %>
<script type="text/javascript">
var eventName = typeof(Turbolinks) !== 'undefined' ? 'page:change' : 'DOMContentLoaded';
document.addEventListener(eventName, function() {
console.log("hello");
<% if flash[:notice] %>
ShopifyApp.flashNotice("<%= escape_javascript flash[:notice].html_safe %>");
<% end %>
<% if flash[:error] %>
ShopifyApp.flashError("<%= escape_javascript flash[:error].html_safe %>");
<% end %>
});
</script>
<% end %>
is the code for partial
respond_to do |format|
if @timer.save
flash[:notice]="updated"
format.html{render :partial => "layouts/flash_messages", :locals => {:flash => flash}}
else
flash[:error]="error"
format.html{render :partial => "layouts/flash_messages", :locals => {:flash => flash}}
end
is the controller code .
:javascriptcontent store. Usually thiscontent_fortechnique has a corresponding<%= yield :javascript %>or<%= content_for :javascript %>elsewhere in a layout.