But maybe it's because I enter the 2nd form from the 1st form right away, without passing through browse (in the button object, I put -1 as RECORD_ID to go to edit mode directly)
Here is my JS I have on the 1st form on which there is the button to go to the 2nd form with pre entered field:
Code: Select all
function nuSelectBrowse(e) {
var r = $('#' + e.target.id).attr('data-nu-primary-key');
window.ENTREPRISE_ID = r;
nuForm(nuGetProperty('form_id'), r, '', '', '1');
}
if (nuFormType() == 'edit') {
nuRunPHPHidden('EntrepriseNomAutoCompletion', 1);
}
function initAutoComplete() {
$("#entreprise_nom").autocomplete({
source: nuGetProperty('arrCompanyNames'),
minLength: 1,
select: function(event, ui) {
$(event.target).val(ui.item.value).change();
}
});
}
And then here is what I have on the 2nd form:
Code: Select all
if (nuFormType() == 'edit') {
$("#contact_entreprise_id").val(window.ENTREPRISE_ID).change();
nuHasNotBeenEdited();
}
function nuSelectBrowse(e) {
var r = $('#' + e.target.id).attr('data-nu-primary-key');
nuSetProperty('MAIN_FORM_RECORD_ID', r);
nuForm(nuGetProperty('form_id'), r, '', '', '1');
}
if (nuFormType() == 'edit') {
nuRunPHPHidden('ContactNomAutoCompletion', 1);
}
function initAutoComplete() {
function setNames(ui) {
setTimeout(function() {
var selectVal = ui.item.value.toString();
var a = selectVal.split(',')
$('#contact_prenom').val(a[0]).change();
$('#contact_nom').val(a[1]).change();
}, 0);
}
$('#contact_prenom').autocomplete({
source: nuGetProperty('arrContactNames'),
minLength: 1,
select: function(event, ui) {
setNames(ui);
}
});
$('#contact_nom').autocomplete({
source: nuGetProperty('arrContactNames'),
minLength: 1,
select: function(event, ui) {
setNames(ui);
}
});
}