I am fairly new to using rails and still getting the hang of things. I have a quick question about an AJAX form that I have set up (with :remote => true) which successfully sends data to the server without reloading the page.
My query is regarding the javascript file that should be executed after the form is submitted. My partial is named '_newsomething.html.erb' and I want to trigger a specific javascript file once the data is posted. Do these javascript files need to correspond with actions in the controller to function correctly in rails? Currently, I have a javascript file named 'create.js.erb' which simply contains a javascript alert, but it doesn't seem to be triggering.
For example, do I need to create a partial called '_create.html.erb' along with a corresponding javascript file 'create.js.erb'? Is there a way to specify within the controller where Rails should look for the javascript file?
Thank you in advance!
EDIT: Below is the code snippet from the Controller (very basic and auto-generated)
def create
@snip = Snip.new(params[:snip])
respond_to do |format|
if @snip.save
format.html { redirect_to(@snip, :notice => 'Snip was successfully created.') }
format.xml { render :xml => @snip, :status => :created, :location => @snip }
else
format.html { render :action => "new" }
format.xml { render :xml => @snip.errors, :status => :unprocessable_entity }
end
end
end