Page 1 of 1

Button to add or refresh select content.

Posted: Sat Oct 15, 2022 5:39 pm
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?

Re: Button to add or refresh select content.

Posted: Sat Oct 15, 2022 9:12 pm
by gerese
Hi , read the last 3 posts here, it may help you .

Re: Button to add or refresh select content.

Posted: Thu Oct 27, 2022 5:21 pm
by kev1n
Hi,

Is this solved or do you still need our support?

Re: Button to add or refresh select content.

Posted: Sun Oct 30, 2022 10:12 am
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.