[英]Angular Stopping event propagation
This is an extension of my previous post here . 这是我以前的扩展张贴在这里 。 I got everything working but I have 1 issue.
我把一切都搞定了,但我有一个问题。 When I start the intro the dropdown opens up exactly like I want, however when I click on the buttons inside the intro window (next, previous) then the dropdown closes.
当我开始介绍时,下拉菜单打开就像我想要的那样,但是当我点击介绍窗口内的按钮(下一个,上一个)时,下拉菜单关闭。 If I navigate the intro using my arrow keys it stays open.
如果我使用我的箭头键导航介绍它保持打开状态。 So how do I get the dropdown to stay open even if I'm using the intro window buttons to navigate the intro.
那么即使我使用介绍窗口按钮导航介绍,如何让下拉列表保持打开状态。
Here's the js portion for reference: 这是js部分供参考:
MainCtrl.prototype.startHelp = function() {
var _this = this;
_this.$timeout(function () {
angular.element('#drop-down').click();
}, 0, false);
_this.CallMe();
};
well you can try adding following to those buttons click event handler functions: 你可以尝试添加以下按钮单击事件处理函数:
function onClickedNext(event) {
...
event.preventDefault();
event.stopPropagation();
}
This may be too late. 这可能为时已晚。 But I achieved this by modifying intro.js code.
但我通过修改intro.js代码实现了这一点。 Just stop the click event propagation inside "nextTooltipButton" defined in intro.js file.
只需停止intro.js文件中定义的“nextTooltipButton”中的单击事件传播即可。
Change the onclick listner function from this : 更改onclick listner函数:
//next button
var nextTooltipButton = document.createElement('a');
nextTooltipButton.onclick = function() {
if (self._introItems.length - 1 != self._currentStep) {
_nextStep.call(self);
}
};
to : 至 :
//next button
var nextTooltipButton = document.createElement('a');
nextTooltipButton.onclick = function() {
if (self._introItems.length - 1 != self._currentStep) {
_nextStep.call(self);
var e = window.event;
e.stopPropagation();
}
};
Works for me on Chrome browser version 56.0.2924.87. 适用于Chrome浏览器版本56.0.2924.87。 As of today this code snippet is here .
截至今天,这段代码片段就在这里 。
We need no other changes in angular side. 我们不需要角度方面的其他变化。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.