2013-03-06 46 views
0

在WordPress的网站,我有加载方面的类别和类别的内容。现在我的内容是用手风琴格式设置的。所以你有一个想法,我在这里做了link我正在处理。我的问题是,你可以看到,当我点击左侧的一个类别时,第一次手风琴起作用,但是当我点击另一个类别时,它完全混乱了。我已经试过几件事情并没有什么doing..here是我到目前为止有:Jquery UI手风琴,加载内容后不刷新

$(document).ready(function() { 
$('.categorias li').click(function(){ 
     var id = $(this).attr('id'); 
     $('#subtitle').html($(this).find('#title').html()); 
    $('#acc').html($('#' + id + '-content').html()).accordion({ 
      autoheight: false 

     }); 

}); 

我也曾尝试:

$('#acc').html($('#' + id + '-content').html()) 
$('#acc').accordion(.accordion({ clearStyle: true }); 

但你可以看到什么做什么。有任何想法吗?

+0

你的JavaScript返回一个错误:'遗漏的类型错误:无法读取null' main.js的特性 'offsetWidth':29。试着先解决它:) – Xavier 2013-03-06 19:13:40

+0

不知道如何解决这个问题,但没有认为这对手风琴工作 – Andres 2013-03-06 20:13:54

回答

0

这可能会或可能不会帮助您简化,但我想我会抛出如何处理手风琴菜单。它缩短了每个标签之间...

<div id="right_area"> 
    <h3><a href="#">New Client Entry:</a></h3> 
     <div id="sub_cat"> 
      <h4><a href="#">this is sub:</a></h4> 
      <div>yo yo</div> 
      <h4><a href="#">this is sub:</a></h4> 
      <div>yo yo</div> 
     </div> 
    <h3><a href="#">Old Client Entry:</a></h3> 
    <div>hello there</div> 
</div> 



$(document).ready(function() { 
    $("#right_area").accordion({ 
     collapsible: true, 
     active: false, 
     clearStyle: true 
    }); 
    }); 


    $("#sub_cat").accordion({ 
     collapsible: true, 
     active: false, 
     clearStyle: true 
    }); 

http://jsfiddle.net/LSg36/2/