2011-03-25 4 views
0

원격 콘텐츠를로드하는 데 효과가있는 jQuery 탭 요소가 있습니다.jQuery는 하나의 사용자 지정 작업을 탭합니다!

그러나 사용자 정의 자바 스크립트를 호출하는 "재설정"이라는 또 다른 단추를 추가하고 싶습니다. jQuery에 익숙하지 않지만 조각을 좋아하고 이것을 수행하는 방법을 찾을 수 없습니다.

현재이 탭을 만드는 .js는 jQuery 사이트의 기본값입니다.

$(document).ready(function() { 
$("#tabs").tabs({ 
     ajaxOptions: { 
      error: function(xhr, status, index, anchor) { 
       $(anchor.hash).html(
        "Couldn't load this tab. We'll try to fix this as soon as possible."); 
      } 
     } 
    }); 
}); 

다음 내 PHP에서는 다음과 같습니다. 새 "재설정"탭에 사용자 지정 작업을 첨부하고 싶습니다.

<div id="tabs"> 
<ul> 
    <li><a href="#map_canvas" title="content">Home</a></li> 
    <li><a href="test.php" title="content">How this works?</a></li> 
    <li><a href="test.php" title="content">View this at home</a></li> 
    <li><a href="#reset" title="content">Reset</a></li> 
</ul> 

<div id="map_canvas"> 
</div> 

</div> 

답변

2

탭에는 생성자 옵션 개체에 넣을 수있는 select 이벤트가 있습니다.

$(document).ready(function() { 
    $("#tabs").tabs({ 
      ajaxOptions: { 
       error: function(xhr, status, index, anchor) { 
        $(anchor.hash).html(
         "Couldn't load this tab. We'll try to fix this as soon as possible."); 
       } 
      }, 
      select: function (event, ui) { // run this when a new tab is clicked 
       if ($(ui.tab).attr('href') == "#reset") { 
        // Do stuff here 
       } 
      } 
     }); 
}); 
+0

위대한, 가장 좋은 솔루션 같았습니다! –

관련 문제