DEVHIDE
        • Home (current)
        • About
        • Contact
        • Cookie
        • Home (current)
        • About
        • Contact
        • Cookie
        • Disclaimer
        • Privacy
        • TOS
        Login Or Sign up

        bootstrap tab('show') not work on dynimcally loaded 'tab-content'

        1.3k Views Asked by Hakan Fıstık At 23 December 2016 at 12:13 2025-12-18T21:45:24.977738

        I am using ASP.NET MVC and boostrap 3

        I am using bootstrap tabs, my main view like this

          <div class="row">
              <div class="tabs-container">
                  <ul class="nav nav-tabs" id="test">
                      <li class="active"><a data-toggle="tab" href="#tab-operations">Operations</a></li>
                      <li class=""><a data-toggle="tab" href="#tab-categories">Categories</a></li>
                  </ul>
                  @Html.Partial("_Ordering", Model)
              </div>
          </div>
        

        the partial view _Ordering like this

        <div class="tab-content" id="ordDiv">
            <div id="tab-operations" class="tab-pane active">
                // some content not important
            </div>
            <div id="tab-categories" class="tab-pane">
                // some content not important
            </div>
        </div>
        

        and I am using unobtrusive-ajax to update the partial view

        @Ajax.ActionLink("cancel", "PartialOrdering", null,
            new AjaxOptions { HttpMethod = "GET", Url = Url.Action("PartialOrdering"), UpdateTargetId = "ordDiv", InsertionMode = InsertionMode.Replace }, null)
        

        the content of the tab updating correctly wihout any problem.

        the problem is i want to show the tab which already was exists before the ajax request refreshed the content. I used js code for this like this

        var a = $('#test li.active').find('a');
        a.click();      // not showing the content of the tab
        a.tab('show');  // also this not showing the content of the tab
        

        the previous code does not make any error in the console, but the desired tab is not shown

        ajax asp.net-mvc twitter-bootstrap tabs partial-views
        Original Q&A
        1

        There are 1 best solutions below

        1
        Aamir Aamir On 23 December 2016 at 13:06

        If you want to show a specific tab here you will need to pass the id of specific anchor tag and based on that anchor you can call the tab() function.

        $(document).ready(function(){
          activeaTab('tab-categories');
        });
        function activeaTab(tab){
          $('.nav-tabs a[href="#' + tab + '"]').tab('show');
        };
        

        https://jsfiddle.net/ewaeLkvv/

        Related Questions in AJAX

        • Ajax jQuery firing multiple time display event for the same result
        • Implement Onfailure in webApi controller
        • AJAX PHP - Reload div after submit
        • ajax load data from mysql
        • Ajax-update only a component attribute, not the whole component nor its children
        • using ajax to get a php database result and then show the result in a button
        • How to prevent browser from executing some JavaScript when person clicks Back button?
        • ajax async: true statement execution order
        • Rails 4.2 jQuery loads only after refresh
        • WebForms GET Json requests (JsonRequestBehavior.AllowGet)
        • Rails - Ajax do not work properly on production server
        • Angular js Button click
        • Make jQuery/AJAX perform instantly on page load
        • jQuery Ajax Uncaught TypeError: Cannot use 'in' operator to search
        • Show success or error messages in Ajax response to Wordpress custom registration form

        Related Questions in ASP.NET-MVC

        • Can MVC.NET prevent SQL-injection at razor or controller level?
        • Getting and passing MVC Model data to AngularJS controller
        • Access property of an object of type [Model] in JQuery
        • Entity Framework Code First with Fluent API Concurrency `DbUpdateConcurrencyException` Not Raising
        • Bundling and minification issue in MVC
        • ASP-MVC Code-first migrations checkbox not active
        • Why does Azure CloudConfigurationManager.GetSetting return null
        • Dynamic roles list in CustomAuthorize ASP MVC
        • Jquery: Change contents of <select> tag dynamically
        • Why web API return 404 when deploy to IIS
        • MVC route URL not containing parameter
        • Invalidate user credentials when password changes
        • MVC : Insert data to two tables
        • MVC - Only allow users to edit their own data
        • Submit Button on Razor View doesn't call Action Result - MVC

        Related Questions in TWITTER-BOOTSTRAP

        • UIWebView Screen Fitting Issue
        • Website zoomed out on Android default browser
        • Twitter Bootstrap horizontal form elements on a line
        • My navbar is not expanding after collapse
        • Reload List after Closing Modal
        • Overwrite Bootstrap style for a single page
        • UI.Bootstrap Angular Typeahead and Firebase Array
        • Bootstrap - Fixed navbar doesn't do what's expected?
        • Bootstrap NavBar with no content on small screens
        • Bootstrap Dropdown Button Problems
        • ScrollBar not showing up - BootStrap
        • Bootstrap flip card with css3 transform
        • bootstrap grid layout questions
        • How do I make jquery events work in a bootstrap modal with dynamic content and selectors?
        • Using GLYPHICONS's free pngs with classes

        Related Questions in TABS

        • SWT CTabFolder doesn't display when running from eclipse
        • Composite Server Templates tabs
        • Preference Screen in SlidingTabLayout
        • Android: Table swipe in fragment goes too far
        • Is it possible for chrome to nest tabs within a tab?
        • Same Tab content over three different pages, how to active the coreesponding tabs according to the page id wordpress
        • How to add a WebView as a content to a tab in JavaFX?
        • Responsive Image on ionic Tab bar
        • Show table when its tab is clicked but hide other tables
        • Change TabItem's Header FontWeight
        • Can I force to keep the chrome tab open via extension?
        • Chrome.runtime.onMessage.addListener on new tab not receiving message from popup.js
        • Tabs in TabLayout not filling up entire ActionBar
        • jquery ui datepicker not working with tabs
        • ResponsiveTabs add onclick in js file

        Related Questions in PARTIAL-VIEWS

        • Adding partial view within partial view
        • C# MVC 5 - How To Get a Table In a Partial View
        • Render same Partial view with different binding
        • How to handle models in partial views
        • Is it a bad idea to use ReportViewer control in MVC 5.2 (.NET 4.5) application
        • dynamically change header based on angular js partial view
        • Why isn't my partial view displaying inside a Kendo tab strip?
        • MVC - Expandable Partial View within ForEach loop
        • Replace Partial View with another
        • MVC5 How to do a post from partialview?
        • Add dynamically Partial view in ASP.NET MVC
        • How to configure a ViewModel and Partial Page to include an IEnumerable
        • bootstrap tab('show') not work on dynimcally loaded 'tab-content'
        • SignalR and MVC 5 partial views
        • How to pass values of partial view models on submit from another partial view

        Trending Questions

        • UIImageView Frame Doesn't Reflect Constraints
        • Is it possible to use adb commands to click on a view by finding its ID?
        • How to create a new web character symbol recognizable by html/javascript?
        • Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
        • Heap Gives Page Fault
        • Connect ffmpeg to Visual Studio 2008
        • Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
        • How to avoid default initialization of objects in std::vector?
        • second argument of the command line arguments in a format other than char** argv or char* argv[]
        • How to improve efficiency of algorithm which generates next lexicographic permutation?
        • Navigating to the another actvity app getting crash in android
        • How to read the particular message format in android and store in sqlite database?
        • Resetting inventory status after order is cancelled
        • Efficiently compute powers of X in SSE/AVX
        • Insert into an external database using ajax and php : POST 500 (Internal Server Error)

        Popular # Hahtags

        javascript python java c# php android html jquery c++ css ios sql mysql r reactjs

        Popular Questions

        • How do I undo the most recent local commits in Git?
        • How can I remove a specific item from an array in JavaScript?
        • How do I delete a Git branch locally and remotely?
        • Find all files containing a specific text (string) on Linux?
        • How do I revert a Git repository to a previous commit?
        • How do I create an HTML button that acts like a link?
        • How do I check out a remote Git branch?
        • How do I force "git pull" to overwrite local files?
        • How do I list all files of a directory?
        • How to check whether a string contains a substring in JavaScript?
        • How do I redirect to another webpage?
        • How can I iterate over rows in a Pandas DataFrame?
        • How do I convert a String to an int in Java?
        • Does Python have a string 'contains' substring method?
        • How do I check if a string contains a specific word?
        .

        Copyright © 2021 Jogjafile Inc.

        • Disclaimer
        • Privacy
        • TOS
        • Homegardensmart
        • Math
        • Aftereffectstemplates