提交.单击"JQuery 事件不起作用"



我尝试搜索并使用您已经在此处发布的一些技巧,但没有一个奏效。我用我的创造性思维和想法撞墙了,这是错的。我有一个模式表单,它会打开,我希望能够在单击提交按钮后隐藏模态,收集字段值并打开聊天界面。这是代码:

$('#confirmation-button').click(function(){

let firstName = $('#first-name').val();
let lastName = $('#last-name').val();
let firstName = $('#email').val();
let firstName = $('#registration-number').val();

let chatConfig = {
"webchatAppUrl": "https://apps.mypurecloud.ie/webchat",
"webchatServiceUrl": "https://realtime.mypurecloud.ie:443",
"orgId": "8410",
"orgName": "fjellinjenas",
"queueName": "Chat",
"logLevel": "DEBUG",
"locale": "",
"data": {
"firstName": firstName,
"lastName": lastName,
"addressStreet": "",
"addressCity": "",
"addressPostalCode": "",
"addressState": "",
"phoneNumber": ""
},
"companyLogo": {
"width": 600,
"height": 149,
"url": "http://i65.tinypic.com/2hr1ytg.jpg"
},
"companyLogoSmall": {
"width": 25,
"height": 25,
"url": "http://i68.tinypic.com/2m3gto6.jpg"
},
"agentAvatar": {
"width": 462,
"height": 462,
"url": "http://i67.tinypic.com/1eqted.png"
},
"welcomeMessage": "Du snakker med kundebehandler.",
"cssClass": "webchat-frame",
"css": {
"width": "100%",
"height": "100%",
"display": "block",
"left": "90%",
}
};
});
ININ.webchat.create(chatConfig, function(err, webchat) {
if (err) {
console.error(err);
throw err;
}
webchat.renderPopup({
width: 400,
height: 400,
title: 'Chat'
});
});

我是初级开发人员,我提前道歉 如果犯了一些初学者错误或类似错误,我仍处于开发阶段:)

提前谢谢你。

干杯。

通过查看您的代码,我可以发现您希望在"chatConfig"准备就绪后立即点击"创建"功能。

由于您无法打开聊天窗口,因此您假设单击事件未触发,但事实并非如此。 我认为您错过了触发网络聊天插件的"创建"功能。

因为,您想在单击按钮时触发它。

将创建方法放在单击函数的回调中。

$('#confirmation-button').click(function(){
let firstName = $('#first-name').val();
let lastName = $('#last-name').val();
let firstName = $('#email').val();
let firstName = $('#registration-number').val();
let chatConfig = {
"webchatAppUrl": "https://apps.mypurecloud.ie/webchat",
"webchatServiceUrl": "https://realtime.mypurecloud.ie:443",
"orgId": "8410",
"orgName": "fjellinjenas",
"queueName": "Chat",
"logLevel": "DEBUG",
"locale": "",
"data": {
"firstName": firstName,
"lastName": lastName,
"addressStreet": "",
"addressCity": "",
"addressPostalCode": "",
"addressState": "",
"phoneNumber": ""
},
"companyLogo": {
"width": 600,
"height": 149,
"url": "http://i65.tinypic.com/2hr1ytg.jpg"
},
"companyLogoSmall": {
"width": 25,
"height": 25,
"url": "http://i68.tinypic.com/2m3gto6.jpg"
},
"agentAvatar": {
"width": 462,
"height": 462,
"url": "http://i67.tinypic.com/1eqted.png"
},
"welcomeMessage": "Du snakker med kundebehandler.",
"cssClass": "webchat-frame",
"css": {
"width": "100%",
"height": "100%",
"display": "block",
"left": "90%",
}
};
ININ.webchat.create(chatConfig, function(err, webchat) {
if (err) {
console.error(err);
throw err;
}
webchat.renderPopup({
width: 400,
height: 400,
title: 'Chat'
});
});    
});

试试这个

$(document).on("click",'#confirmation-button',function(){
//Code...
});

最新更新