单击链接时的页面加载不起作用

时间:2016-09-27 07:25:42

标签: jquery ruby-on-rails turbolinks

我有一个侧栏,其中有一个指向帐户页面的链接。现在点击该侧栏中的帐户,关于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();

          }

        });
}

1 个答案:

答案 0 :(得分:0)

尝试turbolinks:load

$(document).on("turbolinks:load",function(){

    makeProfile();

});
相关问题