Javascript 在Firestore中对文档ID使用Firebase身份验证UID导致网站出现问题
在我的网站上,我有一个表格,上面有我所有用户的列表,我可以在那里编辑他们的个人资料 我遇到的麻烦是只有一些用户允许我编辑他们的详细信息。我注意到问题只发生在我的Firestore中用户的whos文档ID上,例如,以数字开头 4lbkdhe2hirmm9z6iqttndbmh23。其他在ID开头有字母的用户可以正常工作。文档ID是从身份验证中的UID生成的 要编辑用户,将调用包含该表行的文档ID的onclick函数。我试着把ID做成字符串,但没有成功 要创建的表的代码。Javascript 在Firestore中对文档ID使用Firebase身份验证UID导致网站出现问题,javascript,html,google-cloud-firestore,firebase-authentication,Javascript,Html,Google Cloud Firestore,Firebase Authentication,在我的网站上,我有一个表格,上面有我所有用户的列表,我可以在那里编辑他们的个人资料 我遇到的麻烦是只有一些用户允许我编辑他们的详细信息。我注意到问题只发生在我的Firestore中用户的whos文档ID上,例如,以数字开头 4lbkdhe2hirmm9z6iqttndbmh23。其他在ID开头有字母的用户可以正常工作。文档ID是从身份验证中的UID生成的 要编辑用户,将调用包含该表行的文档ID的onclick函数。我试着把ID做成字符串,但没有成功 要创建的表的代码。 function getA
function getAllUser(){
var docRef = db.collection("users");
docRef.get().then(function(querySnapshot) {
querySnapshot.forEach(function(doc) {
html = createJobRow(doc.data(),doc.id);
$('.jobsTable').find('tbody').append(html);
});
jobsDataTable = $('.jobsTable').DataTable({"order": [[ 1, "desc" ]], language: { search: "", searchPlaceholder: "Search...", sLengthMenu: "_MENU_" }, "lengthMenu": [[30, 50, 100, -1], [30, 50, 100, "All"]] });
});
}
function createJobRow(user,id)
{
if(user['role']=='user' )
{
// var user_id = id.toString();
html = '<tr id="'+id+'">';
html += ' <td class="centercheck"><input type="checkbox" class="select-item checkbox selectitem" name="selectitem" id="selectitem" value="'+id+'"/></td>';
html += ' <td class="centercheck">'+id+'</td>';
html += ' <td class="centercheck">'+user['name']+'</td>';
html += ' <td class="centercheck">'+user['company']+'</td>';
html += ' <td class="centercheck">'+user['email']+'</td>';
html += ' <td class="centercheck">'+user['trade']+'</td>';
html += ' <td class="centercheck">'+user['isApproved']+'</td>';
html += '<td class="centercheck"><button type="button" onclick="editInvoice('+id+')" class="btn center-btn"><i class="fa fa-edit"></i></button>';
html += '<button type="button" onclick="editJob('+id+')" class="btn btn-box-tool"><i class="fa fa-user-edit"></i></button></td>';
html += '</tr>';
return html;
}
else {
return null;
}
}
显示用户配置文件的模式
function showModalData(user,id){
var userID = id;
var tableUser = $(userID).find("td:eq(1)").text();
// console.log(user)
$('#jobForm')[0].reset();
modal = $('#jobsAddEditModal');
modal.find('.modal-title').html('Edit Profile');
modal.find('.submit-btn').html('Update Profile');
modal.find('#userid').val(tableUser);
modal.find('#company').val(user['company']);
modal.find('#email').val(user['email']);
modal.find('#expo_token').val(user['expo_token']);
modal.find('#name').val(user['name']);
modal.find('#trade').val(user['trade']);
modal.find('#insurancedocs');
$('#jobsAddEditModal').modal('show');
}
控制台中的错误是(索引):1未捕获的语法错误:无效或意外的令牌我通过向按钮添加ID,然后将文档ID添加到该ID来解决此问题
html += '<button type="button" id="'+id+'" onclick="editJob(this.id)" class="btn btn-box-tool"><i class="fa fa-user-edit"></i></button></td>';
html+='';
我已经解决了这个问题,如果有人有同样的问题,我会回答这个问题。
html += '<button type="button" id="'+id+'" onclick="editJob(this.id)" class="btn btn-box-tool"><i class="fa fa-user-edit"></i></button></td>';