So this is my controller function.
def fb_close
current_user.update_user_points(SHARE_POINT_ONE, message, current_user.id, 0) if params[:post_id].present?
respond_to do |format|
format.js { render :js => "my_function();" }
end
end
and im trying to go back a js function called my_function inside script tag on the same page. I'm getting an error like ActionController::UnknownFormat
I want to know where i was wrong. Please correct me.
I have a file named fb_close.html.erb i can get the call to that file.. Is there any way i can link it with a js function
1 Answer 1
You should be better putting the code of my_function in a separate file of format js and call it like format.js { render 'your_file_name' }
respond_to do |format|
format.js { render 'your_file_name' }
end
You have to create a file like fb_close.js.erb and put the code of my_function in it and call it like this
respond_to do |format|
format.js { render 'fb_close' }
end
6 Comments
my_fucntion? Try moving the code of my_function to separate file like fb_close.js.erb and call it as like this.my_function,do as i said or if you want render just html file,change it to format.html { render 'fb_close' } and file name should be just fb_close.html.erb.Explore related questions
See similar questions with these tags.
my_functionin a separate file of formatjsand call it likeformat.js { render 'your_file_name' }fb_close.js.erbview and call theremy_function();???