Button to add or refresh select content.
Posted: Sat Oct 15, 2022 5:39 pm
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:
In the moment I safe the content I want to close the popup and refresh the select object in the parent form.
This refresh the list, but don't set the value.
Exists an other way to set the value?
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
- 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.
- 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: 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);
}
}
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();
//}
}
}