2013-04-30 39 views
0

我無法獲得手風琴的大小以適應選項卡中的內容。我看到這篇文章,並認爲我可以在點擊標籤時進行簡單刷新:http://bugs.jqueryui.com/ticket/3905。我已經嘗試了幾種方法讓隱藏的標籤顯示手風琴,第一個H3是根據內容進行尺寸調整的,但我無法使其工作。手風琴在標籤頁中並不令人耳目一新

謝謝!

<div class="tab-set" style="display:none;"> 
<ul> 
    <li><a href="#States">States</a></li> 
    <li><a href="#Trending">Trending</a></li> 
    <li><a href="#Map" onclick="setTimeout(function() {initialize();}, 100);">Map</a></li>  
    <li><a href="#Cities">Cities</a></li> 
    <li><a href="#NationalPark">National Parks</a></li> 
    <li><a href="#StatePark">State Parks</a></li> 
    <li><a href="#Information" onclick="$('#accordion').accordion.refresh()">Information</a></li> 
</ul> 
<!-- Hot Locations --> 
<div id="Trending"> 
</div> 
<!-- States --> 
<div id="States"> 
</div> 
<!-- Map --> 
<div id="Map">  
</div> 
<!-- Cities -->  
<div id="Cities"> 
</div> 
<!-- National Parks --> 
<div id="NationalPark"> 
</div> 
<div id="StatePark"> 
</div> 
<div id="Information"> 
    <div id="accordion"> 
     <h3>Description</h3> 
     <p> 
     Almost 70 miles (113 km) west of Key West lies the remote Dry Tortugas National Park. The 100-square mile park is mostly open water with seven small islands. Accessible only by boat or seaplane, the park is known the world over as the home of magnificent Fort Jefferson, picturesque blue waters, superlative coral reefs and marine life, and the vast assortment of bird life that frequent the area.     
     </p> 
     <h3>Operating Hours</h3> 
     <p> 
     Dry Tortugas National Park is open year-round 
     The following limitations apply to specific areas within the park boundary: 
     Garden Key is open year round 24 hours a day. 
     Ft. Jefferson, on Garden Key, is open year-round from sunrise to sunset. 
     Loggerhead Key is open to day visitors year round from sunrise to sunset. All other facilities on the island, including Loggerhead Lighthouse are closed to the public. 
     Bush Key is open to visitors October 15th to January 15th from sunrise to sunset. 
     Hospital Key, and Long Key are closed year round and visitors should remain 100 feet offshore of all closed islands. 
     Middle and East Keys are open to visitors October 16 to March 31 from sunrise to sunset.     
     </p> 
     <h3>Fees</h3> 
     <p> 
     Entrance Fee 
     The entrance fee for the park is $5.00 for visitors 16 and older. This fee covers entrance to the park for 7 days. 
     Entrance Fee Collection 
     Currently, the Yankee Freedom Ferry and Key West Seaplane Adventures collect the park entrance fee from their passengers. If you are the proud owner of a National Parks Pass, Golden Eagle, Golden Age, and Golden Access Passports honored, show your pass at check-in and the entrance fee will be deducted from your transportation cost. 
     If you arrive by private boat, fees are collected through a self service fee area on the main dock at Garden Key. Please note that the park does not have the ability to process credit cards at this fee station. 
     Camping 
     The campground is a self-service fee area with a nightly fee of $3 per person. A 50% discount applies to holders of the Golden Age or Golden Access Pass. No other discounts apply. 
     Camping fees are collected only at the park, seaplane or ferry concessions do not collect camping fees. Please note that the park does not have the ability to process credit cards at this fee station.    </p> 
     </p> 
    </div> 
</div> 

+0

清理了手風琴的html!Ooops!更正了我的onclick to this ... onclick =「$('#accordion')。accordion('refresh');」 – user2332467 2013-04-30 01:41:19

回答

0

fiddle

的JavaScript

首先你需要初始化手風琴,這將設置大小在 'DIV' 的部分,然後初始化選項卡。信息標籤將是一個體面的大小。

我也改變了你的onclick的東西到標籤提供的激活事件。我不知道這其中的#map初始化調用應該去,但如果你只需要運行,一旦有其他事件,你可以註冊揭開序幕的初始化方法

$('#accordion').accordion({heightStyle: "content"}); 
$(".tab-set").tabs({"activate":function(evt,ui){ 
    if(ui.newPanel){ 
     if(ui.newPanel.attr("id")=="Information"){ 
      ui.newPanel.find("#accordion").accordion("refresh"); 
     }else if(ui.newPanel.attr("id")=="Map"){ 
      //you'll need some check to make sure this hasn't fired already 
      //if t/his is an ajax call, move this into a "load":function(evt,ui){} 
      //initialize(); 
     } 
    } 
}}); 

HTML

我改了一下你的html。我通過將<p>包裝在<div>

<div class="tab-set"> 
<ul> 
    <li><a href="#States">States</a></li> 
    <li><a href="#Trending">Trending</a></li> 
    <li><a href="#Map">Map</a></li>  
    <li><a href="#Cities">Cities</a></li> 
    <li><a href="#NationalPark">National Parks</a></li> 
    <li><a href="#StatePark">State Parks</a></li> 
    <li><a href="#Information">Information</a></li> 
</ul> 
<!-- Hot Locations --> 
<div id="Trending"> 
</div> 
<!-- States --> 
<div id="States"> 
</div> 
<!-- Map --> 
<div id="Map">  
</div> 
<!-- Cities -->  
<div id="Cities"> 
</div> 
<!-- National Parks --> 
<div id="NationalPark"> 
</div> 
<div id="StatePark"> 
</div> 
<div id="Information"> 
    <div id="accordion"> 
     <h3>Description</h3> 
     <div><p> 
     Almost 70 miles (113 km) west of Key West lies the remote Dry Tortugas National Park. The 100-square mile park is mostly open water with seven small islands. Accessible only by boat or seaplane, the park is known the world over as the home of magnificent Fort Jefferson, picturesque blue waters, superlative coral reefs and marine life, and the vast assortment of bird life that frequent the area.     
     </p></div> 
     <h3>Operating Hours</h3> 
     <div><p> 
     Dry Tortugas National Park is open year-round 
     The following limitations apply to specific areas within the park boundary: 
     Garden Key is open year round 24 hours a day. 
     Ft. Jefferson, on Garden Key, is open year-round from sunrise to sunset. 
     Loggerhead Key is open to day visitors year round from sunrise to sunset. All other facilities on the island, including Loggerhead Lighthouse are closed to the public. 
     Bush Key is open to visitors October 15th to January 15th from sunrise to sunset. 
     Hospital Key, and Long Key are closed year round and visitors should remain 100 feet offshore of all closed islands. 
     Middle and East Keys are open to visitors October 16 to March 31 from sunrise to sunset.     
     </p></div> 
     <h3>Fees</h3> 
     <div><p> 
     Entrance Fee 
     The entrance fee for the park is $5.00 for visitors 16 and older. This fee covers entrance to the park for 7 days. 
     Entrance Fee Collection 
     Currently, the Yankee Freedom Ferry and Key West Seaplane Adventures collect the park entrance fee from their passengers. If you are the proud owner of a National Parks Pass, Golden Eagle, Golden Age, and Golden Access Passports honored, show your pass at check-in and the entrance fee will be deducted from your transportation cost. 
     If you arrive by private boat, fees are collected through a self service fee area on the main dock at Garden Key. Please note that the park does not have the ability to process credit cards at this fee station. 
     Camping 
     The campground is a self-service fee area with a nightly fee of $3 per person. A 50% discount applies to holders of the Golden Age or Golden Access Pass. No other discounts apply. 
      Camping fees are collected only at the park, seaplane or ferry concessions do not collect camping fees. Please note that the park does not have the ability to process credit cards at this fee station.    </p></div> 
    </div> 
</div> 
+0

這有效!我初始化了手風琴,但沒有使用高度風格。謝謝! – user2332467 2013-04-30 17:51:17