问题
I'm working in a scala application with playframework, I want to use the popover confirm in a smart-table, I did the install for the popconfirm ("popconfirm":"0.4.3") and it works well except in the table exactly in <td>
there is a part of my code:
<table st-table="topics" st-safe-src="topicList" class="table table-striped">
<thead>
<tr>
<th st-sort="domain">Domain</th>
<th class="text-center">Actions</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="topic in topics">
<td>{{topic.domain}}</td>
<td class="text-center">
<div class="btn-group btn-group-xs">
<a href="javascript:void(0)" data-toggle="tooltip" data-original-title="Edit" class="btn btn-default" ng-click="showTopic(topic)" title><i class="fa fa-pencil"></i></a>
<button href="" type="submit" data-toggle="tooltip" data-original-title="Remove" class="btn btn-danger popconfirm" ng-click="removeTopic(topic)" title><i class="hi hi-remove"></i>
</button>
<button type="submit" class="btn btn-success popconfirm" href="@routes.Application.index()">Test</button>
</div>
</td>
<button type="submit" class="btn btn-success popconfirm" href="@routes.Application.index()">Work</button>
</tr>
</tbody>
</table>
<script src="@routes.Assets.versioned("temp/js/vendor/jquery-1.12.0.min.js")"></script>
<script type="text/javascript">
$(document).ready(function() {
$(".popconfirm").popConfirm();
});
</script>
the confirm button "work" is working well but test doesn't work, any help please?
回答1:
The above code is not working because, it is calling $(".popconfirm").popConfirm();
method before rendering ng-repeat
(it render content lazily) content. So it is doing nothing.
For solving the issue, you need to create a directive that will enable popConfirm
feature on that button
once it get render by ng-repeat
. You could use directive link
function to get angular compiled element
to call popConfirm()
method of it.
Directive
app.directive('popconfirm', function(){
return {
restrict: 'C',
link: function(scope, element){
element.popConfirm();
}
}
})
来源:https://stackoverflow.com/questions/35915122/popconfirm-doesnt-work-in-table-td