我制作了一个自定义contextmenu
指令。我正在尝试在contextmenu
打开时记录某些内容。但是当它应该运行一次时,相同的功能运行5次。我想e.stopPropagation()
;但CSS
从第一次开始就不适用,我必须再次点击,然后才能正常工作。我究竟做错了什么?
以下是指令中我的链接功能的显示方式:
$ele.on('contextmenu', '*', function(e) {
e.preventDefault();
e.stopPropagation();
$scope.$apply(function () {
$scope.visible = true;
$('.parented').css({left:e.pageX, top:e.pageY, position: 'absolute'}).show();
var ele = e.target;
$scope.souls = {
elementType: ele.nodeName,
content: ele.innerText,
id: ele.id,
class: ele.className
}
console.log($scope.souls)
})
});
HTML
<div prevent visible="isVisible" ravi="someData" sound="sound(souls)" souls="souls">
<p class="haseebtesting">abc</p>
<table class="datatable">
<tr ng-repeat="t in templateData">
<td class="haseebtesting" ng-click="current.selected = t; confusedFunction(t)" id="{{'test ' + $index}}">{{t.templateName}}</td>
<td>{{t.templatePath}}</td>
</tr>
</table>
{{souls}} <br /><br />
<div ng-if="isVisible" class="parented">
<div class="btn-group-vertical notclick" role="group" aria-label="Vertical button group">
<form class="haseebform">
<input type="text" ng-model="souls.entername" placeholder="Enter name"> <br>
<input type="text" ng-model="souls.entercomment" placeholder="Enter comment">
<input type="button" class="btn btn-info" ng-click="addT(souls)" value="Submit">
</form>
</div>
</div>
</div>