Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Display element onLoad event not firing

Questions related to using nuBuilder Forte.
Locked
tonyd
Posts: 68
Joined: Sun Mar 04, 2018 6:38 pm

Display element onLoad event not firing

Unread post by tonyd »

I have a Display object that shows the result of a SQL calculation. I tried setting the Custom Code section to run this code on the Load (onload) event:

Code: Select all

if (parseFloat($("#my_object_id").val()) > 0) {
    $("#my_object_id").css("color", "red");
} else {
    $("#my_object_id").css("color","black");
}
However, the onLoad event never seems to set this off. I have checked to see that my code works by setting it to fire under the onBlur event, which all works fine.

Any idea why the onLoad event doesn't fire for this object? Does it have anything to do with the nuLoad() function?
TonyD
admin
Site Admin
Posts: 2815
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Display element onLoad event not firing

Unread post by admin »

TonyD,

I'm not sure what you mean by...
the onLoad event
All you need to do is put it in the Javascript section of the Form you are opening.


Steven
tonyd
Posts: 68
Joined: Sun Mar 04, 2018 6:38 pm

Re: Display element onLoad event not firing

Unread post by tonyd »

Steven,

That is exactly what I did
Capture.JPG
Unfortunately, the Javascript never fires using "onload" as the trigger, but it does if I use "onblur" and then click away from the object.
You do not have the required permissions to view the files attached to this post.
TonyD
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Re: Display element onLoad event not firing

Unread post by toms »

Place the code in your form's Javascript area:

Code: Select all

if(nuFormType() == 'edit') {
  
    if(parseFloat($("#my_object_id").val()) > 0) {
        $("#my_object_id").css("color", "red");
    } else {
        $("#my_object_id").css("color", "black");
    }
  
}
You do not have the required permissions to view the files attached to this post.
tonyd
Posts: 68
Joined: Sun Mar 04, 2018 6:38 pm

Re: Display element onLoad event not firing

Unread post by tonyd »

Thank you Toms. It worked like a champ.
TonyD
admin
Site Admin
Posts: 2815
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Display element onLoad event not firing

Unread post by admin »

.
Locked