Welcome to the nuBuilder Forums!

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

nuPopup() problems

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

Re: nuPopup() problems

Unread post by toms »

If there is no other way to retrieve the record_id, Steven might want to add an attribute like "data-nu-primary-key" to the lookup field.
tonyd
Posts: 68
Joined: Sun Mar 04, 2018 6:38 pm

Re: nuPopup() problems

Unread post by tonyd »

toms-
I have been trying to reverse-engineer where to add such an attribute, but I am having some difficulty in that arena. I know the IDs I am looking for are sitting happily in the POST data, but, unfortunately, that is unreachable using javascript. If I could only figure out a way to do it using PHP. Maybe the gurus out there have a suggestion?
TonyD
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: nuPopup() problems

Unread post by admin »

tonyd,

If I understand you correctly...

Try this on click of your Show Button.

Code: Select all

nuPopup('theformid', $('#thelookupid').val());
Steven
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Re: nuPopup() problems

Unread post by toms »

Steven,
tonyd wrote: Currently, the only way is to put the LookupObjectRecord_id in the 'Code' field of the object, but that just looks ugly.
In this case, $('#thelookupid').val() will cust return the code but not the record id.
toms wrote:If there is no other way to retrieve the record_id, Steven might want to add an attribute like "data-nu-primary-key" to the lookup field.
What about my suggestion?
tonyd
Posts: 68
Joined: Sun Mar 04, 2018 6:38 pm

Re: nuPopup() problems

Unread post by tonyd »

Tried to use a trick I googled to inject a JavaScript variable using PHP from within the index.php file:

Code: Select all

<?php
$mypostdata = json_encode($_POST);
echo "var nuPostData = $mypostdata;";
?>
Unfortunately, $_POST seems to have been nulled out before I could get the data out. Is there somewhere I can get to $_POST data before it is destroyed?
TonyD
tonyd
Posts: 68
Joined: Sun Mar 04, 2018 6:38 pm

Re: nuPopup() problems

Unread post by tonyd »

Got it!

Added a line to nuapi.php

Code: Select all

$f->forms[0]->target	= $P['target'];
$f->forms[0]->nuHash = $_POST['nuHash'];   (line added)
$b = nuButtons($F, $P);
which makes $_POST['nuHash'] variables available via a new window.nuSERVERRESPONSE.nuHash object.

Now I can add JavaScript to my button to open the correct edit form popup:

Code: Select all

nuPopup($('#myLookupObject')[0].dataset.nuFormId,window.nuSERVERRESPONSE.nuHash.myTableField);
This seems like a bit of a dirty hack, but it works. What do you think?
TonyD
tonyd
Posts: 68
Joined: Sun Mar 04, 2018 6:38 pm

Re: nuPopup() problems

Unread post by tonyd »

Well, I took out the line I had added to nuapi.php because I found out there is already a JavaScript-accessible object with the record_ids that I need.

Now I simply write a little JavaScript code for my buttons:

Code: Select all

nuPopup(window.nuSERVERRESONSE.objects[numericalObjectId].form_id, window.nuSERVERRESPONSE.objects[numericalObjectId].value);
The numericalObjectId is used to reference the particular form object in the window.nuSERVERRESPONSE.objects array, which is a zero-based identifier directly related to the object tab order on the form.

Thanks for all of the help.
TonyD
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: nuPopup() problems

Unread post by admin »

.
Locked