Welcome to the nuBuilder Forums!

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

Button to add or refresh select content.

Questions related to customising nuBuilder Forte with JavaScript or PHP.
Post Reply
MonoloEspana
Posts: 7
Joined: Sat Dec 18, 2021 1:59 pm

Button to add or refresh select content.

Unread post by MonoloEspana »

I have made a button to open a popup, to add or change the content of a select list database table.

Code to open the popup:

Code: Select all

// cod Button
$v = $("#pr_li_selectprueba_id option:selected").val(); //  change ID select
$v = $v != '' ? $v : -1; // -1 = add new or selected id field.
nuPopup('634945d043c65a1', $v, '') // change ID of form
In the moment I safe the content I want to close the popup and refresh the select object in the parent form.
  1. If I add new content and save it the nuAfterSave() function isn’t running, only with the second click when the new content already is saved the popup will be closed.
  2. I want to refresh the select and set the list to the new or changed value. The refresh without problems, but only if I delay (timeout) the nuSetValue the value is set.
Code to close popup and refresh select:

Code: Select all

function delay() {
    $val = $('#li_selectprueba_id').val(); 
    parent.nuSetValue('pr_li_selectprueba_id', parseInt($val));
    nuClosePopup();
}

function nuAfterSave(){
    //alert('Actualizar? ');
    if (nuIsIframe() && parent.nuGetProperty('form_id') == '634a505d8d15393') {  // <--- replace with your form id
        parent.nuRefreshSelectObject('pr_li_selectprueba_id', '634a505d8d15393');
        setTimeout(delay, 100);
    }
}
This refresh the list, but don't set the value.

Code: Select all

function nuAfterSave(){
    if (nuIsIframe() && parent.nuGetProperty('form_id') == '6343dcd56cb16d9') {  // <--- replace with your form id
        $val = $('#action_id').val();     
        parent.nuRefreshSelectObject('ej_li_accion_id', '6343dcd56cb16d9');
        //alert('safet ' + $val);       with alert it change
        parent.nuSetValue('ej_li_accion_id', parseInt($val));
         nuClosePopup();
	//}
    }
}
Exists an other way to set the value?
gerese
Posts: 132
Joined: Sun Dec 16, 2018 6:13 pm
Location: România
Has thanked: 30 times
Been thanked: 4 times

Re: Button to add or refresh select content.

Unread post by gerese »

Hi , read the last 3 posts here, it may help you .
nuBuilderForte .... BIG Like !!!
kev1n
nuBuilder Team
Posts: 4299
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: Button to add or refresh select content.

Unread post by kev1n »

Hi,

Is this solved or do you still need our support?
MonoloEspana
Posts: 7
Joined: Sat Dec 18, 2021 1:59 pm

Re: Button to add or refresh select content.

Unread post by MonoloEspana »

Hi Kevin,

I have seen Kevin's answer, but I have not found another solution than the delay.

Thanks for this excellent tool.
Post Reply