Consider the following partial, it gets inserted into a page if someone clicks ajax "add comment" link. The question I have is: Is this the best place to include that javascript?
I thought it was best to put it in the application.js, but because the partial gets added via ajax, the validate method called within $(document).ready block does not get triggered because the form does not exist when the original document is ready. Does that make sense?
Using Rails 2.3.4 and jQuery 1.4.1
Thanks!
<%form_for [@commentable,@comment] do |f|%>
<%= f.text_area :comment, :class=>"required", :minlength=>2%>
<% content_tag :button, :type => :submit do %>
Comment
<% end %>
<%end%>
<script type="text/javascript">
$(document).ready(function(){
$("#new_comment").validate();
});
</script>