我可以在对象“ addable:”中实现诺言。保存新客户端后,添加到slimselect中的id需要等待新的_id。 谢谢
支付给*var Datastore = require('nedb');
var dclipro = new Datastore({filename: '/data/clipro.db', autoload: true});
var selectclipro = new SlimSelect({
select: '#bcofid_clipro',
valuesUseText: false,
addable: function (value) {
var newid = "";
var agrabar = {
name: value,
last_idcuenta: "null",
email: "notdefined@gmail.com",
memo: "not available",
auditlog: moment().format('MMMM Do YYYY, h:mm:ss a')
}
dclipro.update({name: value}, agrabar, options, function (err, numReplaced, upsert) {
if (err) {
console.error(err);
}
newid = upsert._id;
})
iziToast.show({
title: 'Bank',
message: 'New Payee has been saved successfully',
position: 'topRight'
});
return { text: value, value: newid }
},
onChange: (info) => {
console.log('elegido : value ' +info.value);
console.log('elegido : text ' +info.text);
}
})
答案 0 :(得分:0)
SlimSelect,哇,这东西过时了。从文档中看,您的return
对象是可选的,并且只要selectclipro.setData(myNewValue)
可以实际看到{{ 1}}。 (确保您已阅读以上我的其余评论)