使用meteor autoform模式按钮时停止事件传播

使用meteor autoform模式按钮时停止事件传播,meteor,modal-dialog,meteor-autoform,event-propagation,Meteor,Modal Dialog,Meteor Autoform,Event Propagation,我已经创建了一个列表组,该列表组包装在afModal模板中。在每个列表组项中,都有触发不同事件的glyphicon按钮 <div class="list-group"> {{#each getRuns}} {{#afModal title="Edit Run" class="list-group-item" collection="Runs" operation="update" doc=_id formId="editRunForm"}}

我已经创建了一个列表组,该列表组包装在afModal模板中。在每个列表组项中,都有触发不同事件的glyphicon按钮

<div class="list-group">
    {{#each getRuns}}
        {{#afModal title="Edit Run" class="list-group-item" collection="Runs" operation="update" doc=_id formId="editRunForm"}}
                {{#if active}}
                    <span class="glyphicon glyphicon-pause pull-right" name="pause" id="{{_id}}"></span>
                    <span class="badge">Active</span>
                {{else}}
                    <span class="glyphicon glyphicon-remove pull-right" name="delete" id="{{_id}}"></span>
                    <span class="glyphicon glyphicon-play pull-right" name="activate" id="{{_id}}"></span>
                {{/if}}
                <h3>{{name}}</h3>
                <p class="list-group-item-text">Assembly: {{assemblyName}}</p>
                <p class="list-group-item-text">Quantity: {{quantity}}</p>
                <p class="list-group-item-text">Progress: {{completedSteps}} of {{totalSteps}} steps completed</p>
        {{/afModal}}
    {{/each}}
</div
当触发glyphicon单击事件时,它还会触发覆盖的afModal按钮。我已尝试在glyphicon单击事件中包含event.stopPropagation()、event.stopImmediatePropagation()和event.preventDefault(),以防止弹出afModal,但它们都不起作用

以前,列表组被包装在link元素中,看起来像这样

<div class="list-group">
    {{#each getRuns}}
        <a href="{{pathFor 'editRun'}}" class="list-group-item">
                {{#if active}}
                    <span class="glyphicon glyphicon-pause pull-right" name="pause" id="{{_id}}"></span>
                    <span class="badge">Active</span>
                {{else}}
                    <span class="glyphicon glyphicon-remove pull-right" name="delete" id="{{_id}}"></span>
                    <span class="glyphicon glyphicon-play pull-right" name="activate" id="{{_id}}"></span>
                {{/if}}
                <h3>{{name}}</h3>
                <p class="list-group-item-text">Assembly: {{assemblyName}}</p>
                <p class="list-group-item-text">Quantity: {{quantity}}</p>
                <p class="list-group-item-text">Progress: {{completedSteps}} of {{totalSteps}} steps completed</p>
        </a>
    {{/each}}
</div>

{{{#每个getRuns}
{{/每个}}

使用“a”元素(并使用相同的glyphicon click事件处理程序),我能够阻止“a”元素触发。如果可能的话,我真的很想使用afModal模板,但不能每次单击一个glpyhicons时都弹出该模板。有什么建议吗?

该键在调用所有操作之前先调用
preventDefault
,因此会发生变化

'click [name="pause"]': function(event) {
    Meteor.call('pauseRun', event.target.id);
    event.preventDefault();
}

应该有用。当然,对于所有事件处理程序都应该这样做

'click [name="pause"]': function(event) {
    Meteor.call('pauseRun', event.target.id);
    event.preventDefault();
}
'click [name="pause"]': function(event) {
    event.preventDefault();
    Meteor.call('pauseRun', event.target.id);
}