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.
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.
nuPopup() problems
-
- Posts: 785
- Joined: Sun Oct 14, 2018 11:25 am
Re: nuPopup() problems
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.
-
- Posts: 68
- Joined: Sun Mar 04, 2018 6:38 pm
Re: nuPopup() problems
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?
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
Re: nuPopup() problems
tonyd,
If I understand you correctly...
Try this on click of your Show Button.
Steven
If I understand you correctly...
Try this on click of your Show Button.
Code: Select all
nuPopup('theformid', $('#thelookupid').val());
-
- Posts: 785
- Joined: Sun Oct 14, 2018 11:25 am
Re: nuPopup() problems
Steven,
In this case, $('#thelookupid').val() will cust return the code but not the record id.tonyd wrote: Currently, the only way is to put the LookupObjectRecord_id in the 'Code' field of the object, but that just looks ugly.
What about my suggestion?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.
-
- Posts: 68
- Joined: Sun Mar 04, 2018 6:38 pm
Re: nuPopup() problems
Tried to use a trick I googled to inject a JavaScript variable using PHP from within the index.php file:
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?
Code: Select all
<?php
$mypostdata = json_encode($_POST);
echo "var nuPostData = $mypostdata;";
?>
TonyD
-
- Posts: 68
- Joined: Sun Mar 04, 2018 6:38 pm
Re: nuPopup() problems
Got it!
Added a line to nuapi.php
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:
This seems like a bit of a dirty hack, but it works. What do you think?
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);
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);
TonyD
-
- Posts: 68
- Joined: Sun Mar 04, 2018 6:38 pm
Re: nuPopup() problems
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:
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.
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);
Thanks for all of the help.
TonyD