Accordion加载了内容以后 无法加载jquery的accordion效果

WBOY
Release: 2016-06-06 20:14:51
Original
1178 people have browsed it

<code>   ' <script>
    $(document).ready(function(){
    $('#accordion').accordion({collapsible: true,active:false,heightStyle: 'content',event: 'click hoverintent'});
    $('#category a').click(function(){
    var page =$(this).attr('href');
    $('#accordion').load('../php/'+page+'.php').accordion('refresh');              
    
    return false;
    });
    });'
</script></code>
Copy after login
Copy after login
<code>   内容显示正常(accordion的效果在第一次加载的时候也正常),但是accordion的效果会在load新的内容之后失去(php出来的内容正常,就是失去了jqueryui的accordion的效果)。我尝试用destroy和重新加载一个新的accordion但是依然没办法。</code>
Copy after login
Copy after login

回复内容:

<code>   ' <script>
    $(document).ready(function(){
    $('#accordion').accordion({collapsible: true,active:false,heightStyle: 'content',event: 'click hoverintent'});
    $('#category a').click(function(){
    var page =$(this).attr('href');
    $('#accordion').load('../php/'+page+'.php').accordion('refresh');              
    
    return false;
    });
    });'
</script></code>
Copy after login
Copy after login
<code>   内容显示正常(accordion的效果在第一次加载的时候也正常),但是accordion的效果会在load新的内容之后失去(php出来的内容正常,就是失去了jqueryui的accordion的效果)。我尝试用destroy和重新加载一个新的accordion但是依然没办法。</code>
Copy after login
Copy after login

<code>$(document).ready(function() {
  $('#accordion').accordion({
    collapsible: true,
    active: false,
    heightStyle: 'content',
    event: 'click hoverintent'
  });
  $('body').on('click', '#category a', function() {
    var page = $(this).attr('href');
    var php = $('#accordion').load('../php/' + page + '.php', function() {
      $('#accordion').accordion('destroy').accordion({
        collapsible: true,
        active: false,
        heightStyle: 'content',
        event: 'click hoverintent'
      });
    });
    return false;
  });
});</code>
Copy after login

在Stackover Flow找到问题答案了。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template