I have a button with remote => true that calls a popup (jQuery popup, not real) like this:
$modal = $('#modal') $modal_close = $modal.find('.close') $modal_container = $('#modal-container') $task_select_div = $('.activity_task_add')
In this popup, I have another form with remote_tag in the submit button of this form that I invoke and an action that has the following code below:
respond_to do |format| if @task.save format.html { redirect_to @task, notice: 'Task was successfully created.' } format.json { render json: @task, status: :created, location: @task } format.js {render :partial => 'tasks', :locals => {:tasks => current_user.department.tasks}} else format.html { render action: "new" } format.json { render json: @task.errors, status: :unprocessable_entity } end end
It executes format.js and the console says “Rendered tasks / _tasks.html.erb (5.8ms)”, but the callback for ajax call does not work.
$('form[data-remote]').on 'ajax:success', (xhr, data, status) -> alert(data)
I need to get the ajax: success event to hide the popup. Any help?
source share