javascript - Rails 4: Dynamically rendering a form on the same page with AJAX -
i seem having trouble finding information on how go dynamically presenting forms on same view. mean is, example, user clicks "add sub-element" link on show view "element", , presented small form adding sub-element, , of course same type of thing editing existing sub-elements, on same show view using ajax/js/jquery or something.
i trying rest-in-place, no avail, have several nested objects (some within other nested objects), , doesn't seem work in-line-editing.
i believe lack of information coming using incorrect search terminology, appreciated point me in right direction.
thanks in advance.
there lot of different ways it, 1 using remote forms, railscasts example or detailed answer on question. call controller jquery , render (similar code here):
in javascript:
$(document.body).on('click', '#user-list-body', function (e) { var url = '/get_user_list/ $.ajax({ url: url, datatype: 'html', type: 'get', success: function(data){ $('#user_table tbody').append(data); } }); });
in controller (note: drastically simplified version):
def get_user_list @users = user.all respond_to |format| format.html { render :layout => false, :partial => 'users/users_list'} end end
Comments
Post a Comment