add a next button to form.

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
bescott53

add a next button to form.

Post by bescott53 » 2018-11-13 13:42

Hi Board, I have updated one of the input forms and changed it to a TAB format.

I need to add a next button to the bottom, this is ok, sortd this but cant get the links to work, has anyone done this before?

I tried to get the TAB link by hovering over it and I copied this but just get a blank screen.

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

Re: add a next button to form.

Post by sjohn » 2018-11-13 16:20

Do you mean that you need to create a link that directs to a specific tab in the detail view?
If - then I would also like to know. I have tried, but cannot have it to function. I have tried with the link shown ( like linking to an anchor ) - but it does not function.
Maybe I need the/a magic word ;-)

bescott53

Re: add a next button to form.

Post by bescott53 » 2018-11-14 10:36

sjohn, i may have a solution, added this into the templates/xxxxxxx_templateDV.html file


Code: Select all

$j('#BI_Next').click(function(e){
 
e.preventDefault();
 
$j('#form-tabs').find("li.active").removeClass('active');
$j('#form-tabs a[href="#INSERT_YOUR_TAB_NAME_THAT_YOU_WANT_TO_GO_TO_HERE"]').parent().addClass('active');
$j('#form-tabs #INSERT_THE_TAB_NAME_YOU_ARE_MOVING_FROM_THE_CURRENT_ACTIVE_ONE').removeClass('active');
$j('#form-tabs #INSERT_YOUR_TAB_NAME_THAT_YOU_WANT_TO_GO_TO_HERE').addClass('active');
 
})

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

Re: add a next button to form.

Post by pbottcher » 2018-11-14 14:30

Hi,

this would work if you have only 2 tabs. If you want you can make it a bit more generic if you have more tabs to navigate through.

You can put the code (with the button creation code) in the hooks folder to the tablename-dv.js file, so it will not be overwritten once you recreate the code.

Code: Select all

$j('#BI_Next').click(function(e){
 
e.preventDefault();

			links = $j('.nav-tabs').find('a');
			hrefs = $j.map(links, link => $j(link).attr('href'));
			actual = $j('.nav-tabs .active a').attr('href');
			idx = hrefs.indexOf(actual);
			if(idx >=0 && idx <= hrefs.length - 2) { // check index is in array bounds
				follow=hrefs[idx+1]; // return whatever comes next to item
			}
			else follow = actual;
			
		 $j('.nav-tabs a[href="'+follow+'"]').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.

Post Reply