ruby - Rails 4 form remote update div issue -
i'm having problems update div after submitting form rails 4. here relevant part of code:
view:
_details.html.haml
= form_tag(url_for(save_answer_path(format: :js)), remote: true) (some html code ....) = submit_tag t('app.bouton.send'), id: 'sendbutton' %div#divlogs = render partial: 'logs'
controller:
def save_answer code ... respond_to |format| format.js end end
js:
save_answer.js.erb
$('#divlogs').html("<%= escape_javascript(render partial: 'logs') %>");
when submit, called correctly i'am getting incorrect output. want update div, instead page have on js file, content of partial.
example:
my url after submitting:
http://domaine/controller/save_answer.js
what on screen:
$('#divlogs').html("<p>this should appear on div </p>");
does know going on?
solution:
as @vladkhomich said in comments above, missing js file rails.js.
you can download here: https://github.com/rails/jquery-ujs/blob/master/src/rails.js
Comments
Post a Comment