I am trying to update a form:
<%= form_for([@group, lesson], remote: true) do |f| %>
<tr id='<%= lesson.id%>' >
<td><%= f.text_field :time %></td>
<td><%= f.text_field :day %></td>
<td><%= f.text_field :subject %></td>
<td><%= f.text_field :teacher %></td>
<td><%= f.text_field :room %></td>
<td><%= f.submit 'Update'%></td>
<td><%= link_to 'Delete', [lesson.group, lesson], remote: true,method: :delete%></td>
</tr>
<%end%>
This is the controller code:
def update
@lesson = @group.lessons.find(params[:id])
@lesson.update_attributes(params[:lesson])
respond_to do |format|
if @lesson
format.html { redirect_to edit_group_path(@group), notice: 'Successfully updated lesson' }
format.js { render :json => @lesson, location: edit_group_path(@group) }
format.json { render json: @lesson}
else
format.html { redirect_to edit_group_path(@group), notice:'Error!' }
format.json { render json: @lesson }
end
end
end
And here is the JavaScript part:
$(document).ready ->
$('#new_lesson').on("ajax:success", (e, data, status, xhr) ->
$('.notice').append data
).bind "ajax:error", (e, xhr, status, error) ->
$('.notice').append '<p>ERROR:'+error+'</p>'
$(".edit_lesson").on("ajax:success", (e, data, status, xhr) ->
$('.notice').append data
).bind "ajax:error", (e, xhr, status, error) ->
$('.notice').append '<p>ERROR:'+error+'</p>'
Although the request goes through successfully and entries are updated, I keep getting a syntax error in the '.notice' section:
SyntaxError: Unexpected token :
I have tried other solutions found online, but none of them seem to work for me.