Page 1 of 1

Close or Abort Form after Clone

Posted: Wed Feb 17, 2021 1:37 am
by icoso
Is there a function or button function or any function that once I execute a Clone Function of the existing form record, that I can abort this clone or close it WITHOUT saving? I have searched for hours to try to find something in these forums and cant find anything examples how to exit out of a form and NOT save it. I don't want to just click on the nuBuilder Form item at the top. I am wanting a button on the form once I click Clone that will "Exit without saving." the current form Im editing. This to prevent my users from saving a cloned rather than edited form by mistake.

I already have the button on the heading to "Exit-No Save", and have already got the if nuIsClone() { alert(); } working. I just need to know the actual method, function, code to exit the form without saving instead of the alert(). Preferably, I'd like it to go back to the Search/browse screen and reset the search.

Besides the Javascript and PHP functions in the wiki, and the code repository (Ive looked for examples there too), is there anything else that would be helpful in finding this type of info out?

Re: Close or Abort Form after Clone

Posted: Wed Feb 17, 2021 2:59 am
by kev1n
icoso wrote:Is there a function or button function or any function that once I execute a Clone Function of the existing form record, that I can abort this clone or close it WITHOUT saving?

Code: Select all

nuHasNotBeenEdited();
nuOpenPreviousBreadcrumb();

Re: Close or Abort Form after Clone

Posted: Wed Feb 17, 2021 8:22 pm
by icoso
That worked exactly as I wanted. It closed the screen and exited to the previous search screen. Thanks!

Re: Close or Abort Form after Clone

Posted: Mon Mar 01, 2021 4:31 pm
by getNo
kev1n wrote:
icoso wrote:Is there a function or button function or any function that once I execute a Clone Function of the existing form record, that I can abort this clone or close it WITHOUT saving?

Code: Select all

nuHasNotBeenEdited();
nuOpenPreviousBreadcrumb();
I did not found this function in the wiki. Is there a way to go multiple crumbs backwards?

Re: Close or Abort Form after Clone

Posted: Mon Mar 01, 2021 5:40 pm
by kev1n
nuOpenPreviousBreadcrumb() is new in Version 4.5 and it's not yet documented in the Wiki.

To go back multiple Breadcrumbs, use this function:

E.g. this would go back 2 Breadcrumbs.

Code: Select all

nuOpenPreviousBreadcrumb(2)

Code: Select all

function nuOpenPreviousBreadcrumb(b) {

	// If a popup is open, close it
	if (parent.$('#nuModal').length > 0) {
		nuClosePopup();
		return;
	}

	if (b === undefined) {
		var b = -2; 
	} else {
		b = b + 1;
	}
 
	var l = window.nuFORM.breadcrumbs.length;
	if (l > 1) {
		nuGetBreadcrumb(l - b);
	}
}

Re: Close or Abort Form after Clone

Posted: Fri Mar 05, 2021 11:39 am
by getNo
Worked.
Thank you for the fast reply.