0

I am using jquery UI tabs and want to know that , is it possible to point a div's id which is not present in

the main tab div container, means

<div id="tabs">
    <ul>
        <li><a href="#tabs-1">tab1</a></li>
        <li><a href="#tabs-2">tab2</a></li>
        <li><a href="#outerdiv">tab3</a></li>
    </ul>
    <div id="tabs-1">
        <p>Tab 1</p>
    </div>
    <div id="tabs-2">
        <p>Tab 2</p>
    </div>
</div>

<div id="outerdiv">
        <p>Tab 3</p>
    </div>

I tried this but div#outer contents not opening when i click on tab3. How can i do this?

3
  • Without changing the source (of jquery ui tabs) or doing some hack (moving the outer div using code) .... no Commented Jun 15, 2012 at 15:14
  • @ManseUK You don't need to edit the source of jquery ui tabs to get this to work, you can make use of the load method, but its still not very tidy.. Commented Jun 15, 2012 at 15:20
  • @Curt +1 on your answer - but like you say - its untidy and would need to be modified for each different case ... Commented Jun 15, 2012 at 15:22

2 Answers 2

2

I believe the default jQuery plugin is looking $(this).find("#outerdiv") (where this=#tabs) which your element is not.

There are ways of getting this to work, but I think the neatest thing to do would be to move #outerdiv into #tabs.

If you insist on keeping the markup the same, you can make use of the load method like so:

$("#tabs").tabs({
 load: function (event, ui) {
    switch (ui.index) {
       case 2:
           $("#tabs div").hide();
           $("#outerdiv").show();
           break;
    }
}
});

But I don't know how this will affect the rest of your tab panels. You'll probably have to add them all into this switch function.

Sign up to request clarification or add additional context in comments.

Comments

1

You could move the div using .appendTo() before initialising the tabs :

$("#outerdiv").appendTo("#tabs");

Working example here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.