单击 link 时页面加载无效
Page load on click of link, does not work
我有一个侧边栏,其中有一个 link 到帐户页面。现在单击该侧边栏中的帐户,有关 javascript 的内容未执行,但是如果我重新加载页面,它会正常执行。我无法理解这种行为。谁能帮我理解这个问题
$(document).on("ready page:load",function(){
makeProfile();
});
function makeProfile(){
$('#profile-form').hide();
$('.profile-edit').on("click",function(e){
// if they click on edit, show the form, other wise show the divs
if($('.profile-edit').text() == "Edit"){
$('.profile-edit').text("Save");
$('.profile-details').hide();
$('#profile-form').show();
}else{
$('.submit-hidden').click();
}
});
}
尝试turbolinks:load
$(document).on("turbolinks:load",function(){
makeProfile();
});
我有一个侧边栏,其中有一个 link 到帐户页面。现在单击该侧边栏中的帐户,有关 javascript 的内容未执行,但是如果我重新加载页面,它会正常执行。我无法理解这种行为。谁能帮我理解这个问题
$(document).on("ready page:load",function(){
makeProfile();
});
function makeProfile(){
$('#profile-form').hide();
$('.profile-edit').on("click",function(e){
// if they click on edit, show the form, other wise show the divs
if($('.profile-edit').text() == "Edit"){
$('.profile-edit').text("Save");
$('.profile-details').hide();
$('#profile-form').show();
}else{
$('.submit-hidden').click();
}
});
}
尝试turbolinks:load
$(document).on("turbolinks:load",function(){
makeProfile();
});