How to specify URL to a tab

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
sjohn
Veteran Member
Posts: 86
Joined: 2018-05-23 09:32

How to specify URL to a tab

Post by sjohn » 2018-11-15 12:49

I have a question much like the "add a next button to a form"

I can specify a URL that directs to a detail-view.
Could be something like this : http://eksempelsite.dk/engdr/eng_firms_ ... ectedID=26

This detail view has two tabs.
The tab "Home" is the default.
If you hover the home, or ( mouse right click - copy link address ) you will see :
http://eksempelsite.dk/engdr/eng_firms_ ... tomer-info

If you hover the other tab ( additional info ) you will see : http://eksempelsite.dk/engdr/eng_firms_ ... dress-info

There could have been more tabs in a detail view.

How do you specify a/the URL that directs to the detail view, but also to a specific tab????

And should there be done something in a hook.

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: How to specify URL to a tab

Post by pbottcher » 2018-11-15 17:06

Hi,
I'll try to give it a shot.

I think, as the page is recreated with tabs after the initial call, you will not be able to get directly to a tab, but if you use the information in the URL and use javascript, you should be able to extract the "#...." information which indicates to which tab you want to navigate and then you should be able to activate this tab.

You can activate your tab via

Code: Select all

$j('.nav-tabs a[href="'+TABINFO+'"]').tab('show');

where TABINFO is your "#...." like the #address-info.

Hope it helps
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

sjohn
Veteran Member
Posts: 86
Joined: 2018-05-23 09:32

Re: How to specify URL to a tab

Post by sjohn » 2018-11-16 07:53

Hello pböttcher

Thank you for responding.

I guess the URL should still be the one shown - but - how/where to use the code you have given?

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: How to specify URL to a tab

Post by pbottcher » 2018-11-16 08:21

put it in the hooks/eng_firms-dv.js file (if it exisits, or create it). You may need to test if the tabs are already loaded, not sure right now in which order that happens, can't test it now.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

sjohn
Veteran Member
Posts: 86
Joined: 2018-05-23 09:32

Re: How to specify URL to a tab

Post by sjohn » 2018-11-16 09:19

Hello pböttcher
Thanks for quick response.

I created and uploaded eng_firms-dv.js
The content I have tried with is this :

$j('.nav-tabs a[href="'+TABINFO+'"]').tab('show');

and this

$j(function(){
$j('.nav-tabs a[href="'+TABINFO+'"]').tab('show');
});

The URL I use is this : http://eksempelsite.dk/engdr/eng_firms_ ... dress-info

It seems to have no effect

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: How to specify URL to a tab

Post by pbottcher » 2018-11-16 10:25

Hi,

can you try $j('.nav-tabs a[href="#address-info"]').tab('show');
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

sjohn
Veteran Member
Posts: 86
Joined: 2018-05-23 09:32

Re: How to specify URL to a tab

Post by sjohn » 2018-11-16 11:08

Hi

I tried it - but still no effect

sjohn
Veteran Member
Posts: 86
Joined: 2018-05-23 09:32

Re: How to specify URL to a tab

Post by sjohn » 2018-11-16 11:15

Hello again.

made a mistake.
The last one functions

sjohn
Veteran Member
Posts: 86
Joined: 2018-05-23 09:32

Re: How to specify URL to a tab

Post by sjohn » 2018-11-16 11:19

But of course it now directs to that tab always. I guess you wanted to know about the syntax.

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: How to specify URL to a tab

Post by pbottcher » 2018-11-16 11:31

Hi, you will need to check the calling url, otherwise it will always redirect.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

sjohn
Veteran Member
Posts: 86
Joined: 2018-05-23 09:32

Re: How to specify URL to a tab

Post by sjohn » 2018-11-16 11:47

Hi. Okay. You mean that I have to check if the url contains #customer-info and then use/set $j('.nav-tabs a[href="#customer-info"]').tab('show');

and check if url contains #address-info" and then use/set $j('.nav-tabs a[href="#address-info"]').tab('show');

Right?

sjohn
Veteran Member
Posts: 86
Joined: 2018-05-23 09:32

Re: How to specify URL to a tab

Post by sjohn » 2018-11-16 11:52

In case I only have two tabs I need only check for the second tab - i guess.
And in case I have 3 tabs, I only have to check for the last 2 ?
Because the first tab is the default.

sjohn
Veteran Member
Posts: 86
Joined: 2018-05-23 09:32

Re: How to specify URL to a tab

Post by sjohn » 2018-11-16 11:56

In this specific case, I should only have to check for the #address-info" and then use/set $j('.nav-tabs a[href="#address-info"]').tab('show');

Is this correct - and how should the check look like?

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: How to specify URL to a tab

Post by pbottcher » 2018-11-16 13:12

Hi,
basically correct, but I would do it rather generic.

Something like:

Code: Select all

	var url_string = window.location.href;
	var idx=url_string.indexOf("#");
	if (idx > 0) {
		$j('.nav-tabs a[href="'+url_string.substring(idx)+'"]').tab('show');
	}
would check if the URL contains the # sign and show the according tab if it was specified in the URL. So this could be used for any amount of tabs.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

sjohn
Veteran Member
Posts: 86
Joined: 2018-05-23 09:32

Re: How to specify URL to a tab

Post by sjohn » 2018-11-16 14:18

Hello pböttcher

You really are a super hero !!!

This functions, it is generel, and it is in a hook. This can be used for all views and without changing the code. And there is no special in it - if the detail-view is shown by a link ( with the ID ) then it is the URL shown on tab mouseover. Perfect.
Thank you

Post Reply