Rank: Member
Groups: Developers, Registered, HelpDesk Joined: 11/7/2018(UTC) Posts: 23
Thanks: 5 times
|
Is there an easy way to make the admin edit-user page jump to a specific tab on page load based on a url parameter? How would you do that? |
|
|
|
|
Rank: Advanced Member
Groups: Administrators, Developers, Registered, HelpDesk, Authorized User, Admin, System Joined: 10/11/2018(UTC) Posts: 110
Thanks: 19 times Was thanked: 18 time(s) in 18 post(s)
|
You can simply change the active class to the tab you want to be selected on page load. For example, if you want the Orders tab active, then remove the active class from Account and apply to Orders tab, two places to update, that are; Code:<li class="active" id="title-tab-5"><a data-toggle="tab" href="#orders">Orders</a></li>
and Code:<div id="orders" class="tab-pane active">
<div class="panel-body " id="user-orders-container">
@Html.Action("UserOrders", new { UserId = ViewBag.UserId })
</div>
</div>
Edited by user Tuesday, March 1, 2022 10:00:24 AM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Member
Groups: Developers, Registered, HelpDesk Joined: 11/7/2018(UTC) Posts: 23
Thanks: 5 times
|
Ok but that hard-codes it. What if I want the active tab to be dynamic based on a url parameter?? I need to send the user to the edit-user page but I want to put them on the tab they need when the page loads. |
|
|
|
|
Rank: Advanced Member
Groups: Administrators, Developers, Registered, HelpDesk, Authorized User, Admin, System Joined: 10/11/2018(UTC) Posts: 110
Thanks: 19 times Was thanked: 18 time(s) in 18 post(s)
|
Hi Joe, To apply the active class dynamically, you have to make some changes inside edituser view file. That are; 1. Get the query string value at top of the page e.g. Locate the following line of code: Code:ViewBag.PageCaption = "Edit User";
and replace with Code:ViewBag.PageCaption = "Edit User";
var currentTab = Request.QueryString["q"];
2. Change the nav tabs li to this: Code:
<li class="@(currentTab == "account" || string.IsNullOrEmpty(currentTab) ? "active": "")" id="title-tab-1"><a data-toggle="tab" href="#account"> Account</a></li>
<li class="@(currentTab == "addresses" ? "active": "")" id="title-tab-2"><a data-toggle="tab" href="#addresses">Addresses</a></li>
<li class="@(currentTab == "purchase-history" ? "active": "")" id="title-tab-3"><a data-toggle="tab" href="#purchase-history">Purchase History</a></li>
...............
3. Similarly, change the view tab contents to this: Code:<div id="account" class="tab-pane @(currentTab == "account" || string.IsNullOrEmpty(currentTab) ? "active": "")">
<div class="panel-body">
@Html.Action("UserAccount")
</div>
</div>
<div id="addresses" class="tab-pane @(currentTab == "addresses" ? "active": "")">
<div class="panel-body" id="user-addresses-container">
@Html.Action("UserAddress", new { id = ViewBag.UserId })
</div>
</div>
<div id="purchase-history" class="tab-pane @(currentTab == "purchase-history" ? "active": "")">
<div class="panel-body ">
@Html.Action("UserPurchaseHistory", new { id = ViewBag.UserId })
</div>
</div>
................
The URL should be something like this: /Admin/User/EditUser/1?q={tabname} Where tabname will be the currentTab value used in query string to match against selected tab. For example, /Admin/User/EditUser/1?q=purchase-history Hope this helps! Edited by user Wednesday, March 2, 2022 9:05:50 AM(UTC)
| Reason: Not specified
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The AbleCommerce Forums uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close