2

I am using the below code to render the bootstrap tab in my MVC application. All the scripts are loaded correctly. but still throwing tab undefined error.

<script src="@Url.Content("~/Scripts/jquery-1.8.3.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/bootstrap-tabs.js")" type="text/javascript"></script>

<ul id="myTab" class="nav nav-tabs">
    <li class="active"><a href="#home" data-toggle="tab">Home</a></li>
    <li><a href="#profile" data-toggle="tab">Profile</a></li>
</ul>
<div id="myTabContent" class="tab-content">
    <div class="tab-pane fade in active" id="home">
        jhgh
    </div>
    <div class="tab-pane fade" id="profile">
        mbjb
    </div>

</div>


<script type="text/javascript">
    $(function () {

        $('#myTab a').click(function (e) {debugger
            e.preventDefault()
            $(this).tab('show');
        });
    });

</script>

Thanks,

Siva

4
  • 1) try without the debugger; 2) Use these markup - getbootstrap.com/javascript/#tabs 3) check for jQuery conflicts Commented Dec 31, 2013 at 13:26
  • thanks.how can i check jquery conflict here ? Commented Dec 31, 2013 at 13:36
  • I'm not very sure, I haven't ever use bootstrap, but find this in the docs - 'You can activate a tab or pill navigation without writing any JavaScript by simply specifying data-toggle="tab"'...so try first without your js :) Commented Dec 31, 2013 at 13:37
  • if the above doesn't help - give us a simple demo in fiddle Commented Dec 31, 2013 at 13:49

2 Answers 2

1

Try to remove "debbuger" WORKING FIDDLE

HTML

<ul id="myTab" class="nav nav-tabs">
  <li class="active">
      <a href="#home" data-toggle="tab">Home</a>
  </li>
  <li>
      <a href="#profile" data-toggle="tab">Profile</a>
  </li>
</ul>
<div id="myTabContent" class="tab-content">
  <div class="tab-pane fade in active" id="home">
      jhgh
  </div>
  <div class="tab-pane fade" id="profile">
      mbjb
  </div>
</div>

JAVASCRIPT

   $(function () {
        $('#myTab a').click(function (e) {
            e.preventDefault()
            $(this).tab('show');
        });
    });
Sign up to request clarification or add additional context in comments.

Comments

0

You should import the complete bootstrap's javascript library, It seems like exists a javascript dependence on bootstraps's files js

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.