I am trying to render a partial after a user clicks a button.
However the following will download the partial html immediately and not after the click:
$('#menu_signup').click(function(){
$('#fade-wrapper').fadeIn();
$('#fade-wrapper').html("<%= escape_javascript(render :partial => 'shared/signup', :remote => true) %>");
});
I can't use the link_to
tag because the button does more in the click than calling only the ajax.
Is there a way to execute the ajax in other way?
Ok I ended up using basic JQuery Ajax:
$('#menu_signup').click(function(){
$('#fade-wrapper').fadeIn();
$.ajax({url: "/signup_login", format: 'js', success: function(result){
}});
});
With a JS:
$('#fade-wrapper').html("<%= escape_javascript(render :partial => 'signup_form', formats: [:html]) %>");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.