Reputation: 31
My controller is:
def create
@group = Group.new(params[:group])
@group.company=current_user.company
respond_to do |format|
if @group.save
format.html { redirect_to(@group, :notice => 'Group was successfully created.') }
format.js
else
flash.now[:error][email protected]_messages
format.html { render :nothing => true }
format.js
end
end
end
create.js.erb is:
$('<%= escape_javascript(render(:partial => @group))%>').appendTo('#groups');
$("#new_group")[0].reset();
Upvotes: 1
Views: 4652
Reputation: 3264
$(".flashnotice").html("<%= escape_javascript(flash[:notice]) %>");
$(".flashnotice").show(300);
You have to add these two lines in your create.js.erb
file. Replace .flashnotice
with the selector for your flash HTML element; e.g., the class name of your flash <div>
.
Upvotes: 7
Reputation: 4950
I think you just need to say <%= flash[:notice] %>
somewhere in your erb file.
Upvotes: -4