Page 1 of 1

add a next button to form.

Posted: 2018-11-13 13:42
by bescott53
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.

Re: add a next button to form.

Posted: 2018-11-13 16:20
by sjohn
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 ;-)

Re: add a next button to form.

Posted: 2018-11-14 10:36
by bescott53
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');
 
})

Re: add a next button to form.

Posted: 2018-11-14 14:30
by pbottcher
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');
}