单击其身体时弹出关闭,如何禁用?

时间:2016-01-07 10:46:45

标签: angularjs

单击以将光标聚焦在Popover正文

上时,弹出窗口内容始终关闭

这里是我的popover指令

 angular.module('collect').directive('popover', function($timeout){
    return {
        restrict : 'E',
        replace : true,
        link: function(scope, element, attrs) {
            var popover = null;
            // define popover for this element
            $timeout(function() {
                // TODO: maybe can continue using $(element) or just element instead of saving popover var
                popover = $(element).popover({
                    html: true,
                    placement: scope.placement || "top",
                    // grab popover content from the next element
                    content: $(element).siblings(".pop-content").contents(),
                });
                popover.on('show.bs.popover', function($event) {
                    //hide any visible popover
                    $('.popover').not($(element)).popover('hide');
                });
            },0 , false);

            var unbinder = scope.$on(
                "$destroy",
                function handleDestroyEvent() {
                    if (popover) {
                        popover.off('show.bs.popover');
                        popover = null;
                    }
                    $(element).off('.popover.data-api'); // TODO: I think this is only for jquery, not bootstrap
                    $(element).popover('destroy');
                    element.remove();
                    unbinder();
                }
            );

            $("body").on("click touchstart", '.popover', function() {
                $(this).popover("show");
                $('.popover').not(this).popover("hide"); // hide other popovers
                return false;
            });
        }
    };
});

这就是我如何使用popover

<span>
<popover class="tbl-act-btn action-column action-column-ic popover-btn" title="Comments">
    <span title="{{columnName}}">
        <i class="fa" ng-class="{'fa-comments-o' : !isComment(commentContentTemp), 'fa-comments' : isComment(commentContentTemp)}"></i>
    </span>
</popover>
<div ng-hide="true" class="pop-content">
    <div class="form-group">
        <textarea class="popover-textarea form-control" name="comment" ng-model="commentContentTemp"></textarea>
        <div class="popover-footer">
           <button type="button"
                class="glyphicon glyphicon-ok btn btn-primary popover-submit" aria-hidden="true" ng-click="updateComment($event)"></button>
           <button type="button" class="glyphicon glyphicon-remove btn btn-default popover-cancel" aria-hidden="true" ng-click="cancelUpdateComment($event)"></button> 
        </div>
    </div>
</div>

单击textArea编辑文本时,它总是关闭Popover。每当点击更新,取消或在Popover之外,我都希望它关闭。

0 个答案:

没有答案