2012-04-30 2 views
1

각 div ID 번호로 식별되는 축소 된 accordian 항목이 포함 된 페이지로 링크를 만들려고합니다. 내가 만드는 링크를 만들려면 어떻게해야합니까접힌 아코디언에서 항목에 대한 링크를 만들려면 어떻게해야합니까?

itemPreviewTitle accordionHeader ui-accordion-header ui-helper-reset ui-state-default ui-corner-all" role="tab" aria-expanded="false" aria-selected="false" tabindex="-1" style="zoom: 1; 

:

sample.html#itemIdX // opens to the page but not the item 

sample.html?itemIdX // same result 

항목은 H3 클래스를 사용 : 내 링크에 매개 변수를 추가하여 특정 항목을 연결하고 열

실패 시도는 다음과 같다 내 itemX는 확장 된 상태입니까?

+0

내 대답에 해결책을 적용하는 행운이 있었나요? –

답변

0

Accordion API docs이 따르기가 쉽지 않으므로 activate() 기능이 광고 된대로 작동하지 않는 것처럼 보입니다.

질문에 따르면 div ID를 참조하여 아코디언 섹션을 여는 것처럼 들립니다. 이것은 기본적으로 불가능합니다. 0 기반 색인 (예 : 0 = 첫 번째 섹션, 1 = 두 번째 섹션 등) 만 사용하여 섹션을 식별 할 수 있습니다.

이 방법이 작동했다 가졌 : 아코디언을 포함하는 페이지에서

<a href="10387904_Accordion_link_2.html?openAccordionId=0">Open first item</a> 
<a href="10387904_Accordion_link_2.html?openAccordionId=1">Open second item</a> 
<a href="10387904_Accordion_link_2.html?openAccordionId=2">Open third item</a> 

, 쿼리 문자열에서 ID를 추출하려면 다음 코드를 사용하여 :

이 같은 링크를 정의 해당 섹션과 함께 아코디언 초기화 :

// Using the parseQueryString extension from 
// http://paulgueller.com/2011/04/26/parse-the-querystring-with-jquery/ 
$.extend({ 
    parseQuerystring: function() { 
     var nvpair = {}; 
     var qs = window.location.search.replace('?', ''); 
     var pairs = qs.split('&'); 
     $.each(pairs, function (i, v) { 
      var pair = v.split('='); 
      nvpair[pair[0]] = pair[1]; 
     }); 
     return nvpair; 
    } 
}); 

// Get the index of the section we want to open from the querystring. 
var openAccordionId = parseInt($.parseQuerystring()["openAccordionId"]); 

// Initialise the accordion with the active section defined. 
var accordion = $("#accordion").accordion({ active: openAccordionId }); 

// Note: for some reason, the following does not work: 
// var accordion = $("#accordion").accordion(); 
// accordion.activate(openAccordionId); 
관련 문제