JavaScript 自定义事件在按下提交按钮后循环发生
JavaScript Custom event is occuring in a loop after pressing submit button
对于在第二个渐进式分析屏幕上单击提交按钮后的 JS 自定义事件event==='afterSubmit'
,整个事件不断重复,直到我将其关闭。我正在使用 e.stopImmediatePropagation();
来停止此事件,但它没有任何提示?
我看到的一件事是,由于您正在使用 afterSubmit 事件,并在其中调用 accounts.showScreenSet,每次您在新屏幕上按提交时,它都会依次再次调用该事件。这可能不是想要的行为。
其次,最好仅在您检查的字段为空而不是满时才触发屏幕。现在的方式意味着如果用户已经填写了该字段,屏幕将始终触发。
你可以试试这个:
if (e.eventName === 'afterSubmit') {
alert('afterSubmit Fired');
if (typeof (e.profile.zip) !== 'undefined') {
if ((e.profile.zip == '') || (e.profile.zip == null)) {
alert('Yo 2nd step..');
alert('Zip is empty, please fill out your zipcode on the next screen');
gigya.accounts.showScreenSet({
screenSet: 'New-RegistrationLogin',
startScreen: 'Bio'
});
}
}
}
此外,在向现有用户的个人资料添加附加信息时,建议的最佳做法是使用 ProfileUpdate 屏幕集中的屏幕,而不是 RegistrationLogin 屏幕集中的屏幕。
对于在第二个渐进式分析屏幕上单击提交按钮后的 JS 自定义事件event==='afterSubmit'
,整个事件不断重复,直到我将其关闭。我正在使用 e.stopImmediatePropagation();
来停止此事件,但它没有任何提示?
我看到的一件事是,由于您正在使用 afterSubmit 事件,并在其中调用 accounts.showScreenSet,每次您在新屏幕上按提交时,它都会依次再次调用该事件。这可能不是想要的行为。
其次,最好仅在您检查的字段为空而不是满时才触发屏幕。现在的方式意味着如果用户已经填写了该字段,屏幕将始终触发。
你可以试试这个:
if (e.eventName === 'afterSubmit') {
alert('afterSubmit Fired');
if (typeof (e.profile.zip) !== 'undefined') {
if ((e.profile.zip == '') || (e.profile.zip == null)) {
alert('Yo 2nd step..');
alert('Zip is empty, please fill out your zipcode on the next screen');
gigya.accounts.showScreenSet({
screenSet: 'New-RegistrationLogin',
startScreen: 'Bio'
});
}
}
}
此外,在向现有用户的个人资料添加附加信息时,建议的最佳做法是使用 ProfileUpdate 屏幕集中的屏幕,而不是 RegistrationLogin 屏幕集中的屏幕。