Welcome to the nuBuilder Forums!

Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.

nuBeforeSave triggered Topic is solved

Questions related to using nuBuilder Forte.
Post Reply
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

nuBeforeSave triggered

Unread post by toms »

Hi,

There's an Object with type "Select" on a form with an onchange event attached.
onchange_event.PNG
The PHP procedure does nothing but output a debug message: nuDebug("Dummy"). Actually, it can be replaced with any other code.
php_cde.PNG
As soon as a value is selected from the dropdown, onchange is fired and hence the PHP code is executed.

Now here is the strange thing: The function nuBeforeSave(), that is declared in the form's javascript, is triggered somehow.

How can I prevent it from triggering? I mean no save action has happend at that time.
You do not have the required permissions to view the files attached to this post.
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Re: nuBeforeSave triggered

Unread post by toms »

Simplified example to replicate the issue:

1. In the Javascript section of a Form add;

Code: Select all

if (nuFormType() == 'edit') {
    nuAddActionButton('nuRunPHPHidden', 'Try me!', 'nuRunPHPHidden("dummy")');   //-- run any php code (hidden)
}

function nuBeforeSave() {
  alert("nuBeforeSave");
}
2. Click the "Try me!" button

3. You'll see an alert 'uBeforeSave' because nuBeforeSave gets triggered for some unknown reason
admin
Site Admin
Posts: 2829
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 30 times

Re: nuBeforeSave triggered

Unread post by admin »

toms,

I have added a parameter for both nuRunPHP() and nuRunPHPHidden() that will allow you to ignore any nuBeforeSave().

http://wiki.nubuilder.net/nubuilderfort ... nPHPHidden

http://wiki.nubuilder.net/nubuilderfort ... t#nuRunPHP

Let me know if they work properly.

Steven
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Re: nuBeforeSave triggered

Unread post by toms »

Steven,

I just tested nuRunPHPHidden() and nuBeforeSave() doesn't trigger anymore.

However, I find the description on the wiki not very clear. Looking at the source code, I figured that I can basically pass any parameter (like 1 to indicate true)

"string2 : optional, if this 2nd parameter is passed, any nuBeforeSave() function will not be run."
admin
Site Admin
Posts: 2829
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 30 times

Re: nuBeforeSave triggered

Unread post by admin »

toms,

My fault, it was working the opposite way it was supposed to.

So the wiki should make sense now.

If you have a better explanation of how it works, I'll put that on the wiki.

I've updated Github.

Let me know if it works now.

Steven
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Re: nuBeforeSave triggered

Unread post by toms »

It works now. Thanks!
admin
Site Admin
Posts: 2829
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 30 times

Re: nuBeforeSave triggered

Unread post by admin »

.
Post Reply