Vote count:
0
I can't seem to load the HTML, I am getting 200 status, and server shows a success process, still can't seem to execute anything inside the .js.erb file.
Link button to call partial: <a> data-target="#user-form-modal" class="register-btn" data-remote="true" data-toggle="modal" data-user-type="1" href="/home/remote_sign_up">Student</a>
Route: get 'home/remote_sign_up', to: 'home#remote_sign_up', as: 'home_remote_sign_up'
home/remote_sign_up.js.erb
if($('.modal').length > 0) {
$("#user-form-modal").modal();
}
else {
$("body").prepend("<%= escape_javascript(render partial: 'remote_sign_up') %>");
$("#user-form-modal").modal();
}
home/_remote_sign_up.slim I have my modal here in which I'm calling.
home_controller.rb
respond_to :html, :json, :js
def index
@subjects = Subject.all
respond_to do |format|
format.html
format.json { render json: Subject.all.pluck(:name) }
end
end
application_controller.rb I have this declared: protect_from_forgery with: :exception
asked 1 min ago
Rails Render partial through ajax
Aucun commentaire:
Enregistrer un commentaire