jQuery仅适用于页面刷新

时间:2017-01-19 05:28:30

标签: angular

我正在Angular2中构建一个应用程序,我在jQuery中有一个手风琴。(我正在构建这个用于php,但我的老板现在想要有角度)。

手风琴在页面加载时工作正常。但是,如果我按下浏览器上的后退按钮(返回页面),则不会再次加载。

我已经安装了打字稿的打字,并在控制器的导入下面声明了declare var $:any

我在这个方法中有我的jQuery。

    ngAfterViewInit() {
    $(document).ready(function($) {
      $('#accordion').find('.accordion-location-header').click(function(){
        //Expand or collapse this panel
        //Reset to default-up
        $('.accordion-location-header').not(this).each(function(index,el){
          $(el).find('i').removeClass('fa-chevron-down').addClass('fa-chevron-up');
        });
        $(this).next().slideToggle('fast');
        $(this).find('i').toggleClass('fa-chevron-up fa-chevron-down');
        //Hide the other panels
        $(".accordion-location-content").not($(this).next()).slideUp('fast');
      });

      $('#accordion').find('.accordion-status-header').click(function(){
        //Expand or collapse this panel
        //Reset to default-up
        $('.accordion-status-header').not(this).each(function(index,el){
          $(el).find('i').removeClass('fa-chevron-down').addClass('fa-chevron-up');
        });
        $(this).next().slideToggle('fast');
        $(this).find('i').toggleClass('fa-chevron-up fa-chevron-down');
        //Hide the other panels
        $(".accordion-status-content").not($(this).next()).slideUp('fast');
      });
    });
  }

0 个答案:

没有答案
相关问题