NuShow() - strange behavior

Questions related to customising nuBuilder Forte with Javascript or PHP.

NuShow() - strange behavior

Unread postby kknm » Thu Apr 08, 2021 9:27 pm

In one main form procedure I call two nuShow ('sub_jurw_if') and nuShow ('but_ok')
Only the subform appears. If you comment out either of the two, it works separately.
Code: Select all
    var dep = $('#obz_dep');   
    var comp = $('#obz_com');
    var dat = new Date().toLocaleDateString();
    $("#sub_jurw_if000dep").val(dep.val());
    $("#sub_jurw_if000computer").val(comp.val());   
    $("#sub_jurw_if000jur_wdata").val(dat);
    nuShow('sub_jurw_if');
    nuShow('but_ok');   

Initially the subform and button are hidden.
kknm
 
Posts: 204
Joined: Sat Apr 11, 2020 7:33 am

Re: NuShow() - strange behavior

Unread postby kknm » Thu Apr 08, 2021 11:27 pm

Added a few more different hidden objects and as many nuShow() to LaunchForm.
Only one object becomes visible anyway. This is not the case in nuBuilder4.
kknm
 
Posts: 204
Joined: Sat Apr 11, 2020 7:33 am

Re: NuShow() - strange behavior

Unread postby kev1n » Thu Apr 08, 2021 11:43 pm

I justed tested it with an old nuBuilder 4 installation by setting the Access of an object to hidden and calling

Code: Select all
nuShow('hidden_object')


Result: The object didn't show up.
kev1n
nuBuilder Team
 
Posts: 1624
Joined: Mon Oct 15, 2018 2:13 am
nuBuilder Version: 4.5

Re: NuShow() - strange behavior

Unread postby kev1n » Fri Apr 09, 2021 12:08 am

I'll have to investigate. For the time being, you can try forceShow() instead of show()
Code: Select all
function forceShow(i, tab) {
   $('#'+ i).attr('data-nu-tab', 'x'+tab);
   $('#label_'+i).attr('data-nu-tab', 'x'+tab);
   nuShow(i);
}


Code: Select all
forceShow('sub_jurw_if', '0'); // 0 means the object is on the first tab, 1 = 2nd tab etc.
forceShow('but_ok', '0');
kev1n
nuBuilder Team
 
Posts: 1624
Joined: Mon Oct 15, 2018 2:13 am
nuBuilder Version: 4.5

Re: NuShow() - strange behavior

Unread postby kknm » Fri Apr 09, 2021 4:03 pm

ForceShow () did not work for me in one function. Added another function with normal nuShow (). The errors in the debugger are the same, but both objects become visible.
Code: Select all
nucommon.js?ts=20210409081413:2052 Argument #2 is not an array in nuAddDatalist()

nucommon.js?ts=20210409081413:983 Uncaught TypeError: Cannot read property 'id' of undefined
    at nuShow (nucommon.js?ts=20210409081413:983)
    at add_jurw (<anonymous>:21:5)
    at HTMLButtonElement.onclick ((index):1)
nuShow @ nucommon.js?ts=20210409081413:983
add_jurw @ VM2136:21
onclick @ (index):1
nucommon.js?ts=20210409081413:983 Uncaught TypeError: Cannot read property 'id' of undefined
    at nuShow (nucommon.js?ts=20210409081413:983)
    at HTMLDivElement.onchange ((index):1)
kknm
 
Posts: 204
Joined: Sat Apr 11, 2020 7:33 am

Re: NuShow() - strange behavior

Unread postby kev1n » Fri Apr 09, 2021 4:18 pm

If you just call

Code: Select all
forceShow('sub_jurw_if', '0');


and nothing else, does that error also appear?
kev1n
nuBuilder Team
 
Posts: 1624
Joined: Mon Oct 15, 2018 2:13 am
nuBuilder Version: 4.5

Re: NuShow() - strange behavior

Unread postby kknm » Fri Apr 09, 2021 4:45 pm

kev1n wrote:If you just call

Code: Select all
forceShow('sub_jurw_if', '0');


and nothing else, does that error also appear?

Yes...
Code: Select all
nucommon.js?ts=20210409100338:2052 Argument #2 is not an array in nuAddDatalist()
nuAddDatalist @ nucommon.js?ts=20210409100338:2052
nuINPUT @ nuform.js?ts=20210409100338:745
nuBuildEditObjects @ nuform.js?ts=20210409100338:546
nuBuildForm @ nuform.js?ts=20210409100338:164
successCallback @ nuajax.js?ts=20210409100338:117
success @ nuajax.js?ts=20210409100338:17
c @ jquery.js?ts=20210409100338:2
fireWith @ jquery.js?ts=20210409100338:2
l @ jquery.js?ts=20210409100338:2
(anonymous) @ jquery.js?ts=20210409100338:2
load (async)
send @ jquery.js?ts=20210409100338:2
ajax @ jquery.js?ts=20210409100338:2
nuAjax @ nuajax.js?ts=20210409100338:8
nuForm @ nuajax.js?ts=20210409100338:122
nuGetBreadcrumb @ nucommon.js?ts=20210409100338:123
onclick @ (index):1
nucommon.js?ts=20210409100338:983 Uncaught TypeError: Cannot read property 'id' of undefined
    at nuShow (nucommon.js?ts=20210409100338:983)
    at forceShow (<anonymous>:46:4)
    at add_jurw (<anonymous>:22:5)
    at HTMLButtonElement.onclick ((index):1)
kknm
 
Posts: 204
Joined: Sat Apr 11, 2020 7:33 am

Re: NuShow() - strange behavior

Unread postby kknm » Fri Apr 09, 2021 4:52 pm

Calling the function
Code: Select all
JSON.stringify(nuSubformObject(''));
not observing the buttons and subform objects.
Code: Select all
"{"id":"nuBuilder4EditForm","foreign_key":"","primary_key":"obz_id","object_id":"605899466482e56","table":"obzor","action":"save","rows":[["-1",0,"","","","","","[]"]],"columns":[[],[],[],[],[],[],[]],"chartData":[[null,null,null,null,null,null],[0,0,0,0,0,0]],"chartDataPivot":[[null,0],[null,0],[null,0],[null,0],[null,0],[null,0]],"edited":[[0,0,0,0,0,0,0,0]],"deleted":[0],"fields":["ID","nuDelete","obz_dep","obz_com","obz_pr","obz_kart","obz_d","sel"]}"
kknm
 
Posts: 204
Joined: Sat Apr 11, 2020 7:33 am

Re: NuShow() - strange behavior

Unread postby kev1n » Fri Apr 09, 2021 5:02 pm

Is there anything (invalid or spaces) in the Datalist field?
Attachments
dl.png
dl.png (11.85 KiB) Viewed 17 times
kev1n
nuBuilder Team
 
Posts: 1624
Joined: Mon Oct 15, 2018 2:13 am
nuBuilder Version: 4.5

Re: NuShow() - strange behavior

Unread postby kknm » Fri Apr 09, 2021 5:22 pm

Yes !
One of the fields had a space in the datalist.The first mistake is gone.
Last edited by kknm on Fri Apr 09, 2021 5:24 pm, edited 1 time in total.
kknm
 
Posts: 204
Joined: Sat Apr 11, 2020 7:33 am

Next

Return to Custom Code

Who is online

Users browsing this forum: No registered users and 8 guests