如何在按下输入时仅提交最高级别的模态?

时间:2017-07-26 14:39:11

标签: angularjs

我有一个角度模块,可打开模态A(查找报告),以便用户输入搜索条件。模态A还有一个字段,可以打开模型B(查找调查员)来搜索和查找模态A的人。

当我按下两个模态打开时,两个查找函数都执行时出现问题。有没有办法可以使我的指令足够聪明,只能在这种情况下执行Modal B上的函数...无论哪个模态最后打开?或具有最高的z指数等。

我的指示

//Put this on a button to make it the default 
.directive('autoEnterDirective', ['$document', function($document) {
return {
  scope: {
      autoEnterDirective: "&"
  },
  link: function(scope, element, attrs) {
    var enterWatcher = function(event) {
      if (event.which === 13) {
        scope.autoEnterDirective();
        scope.$apply();
        ///console.log('ENTER')
        event.preventDefault();
        $document.unbind("keydown keypress", enterWatcher);
      }
    };
    $document.bind("keydown keypress", enterWatcher);
  }
}
}])

我对模态A(查找报告)的标记

<a id="btnFind" class="button small box-shadow-inset" auto-enter-directive="findModal()" ng-click="findModal()">Find</a> 

我对模态B(Find Investigator)的标记

<a id="btnFind" class="button small box-shadow-inset" auto-enter-directive="findModal()" ng-click="findModal()">Find</a>  

1 个答案:

答案 0 :(得分:0)

你遇到了很多问题之一,为什么模态不打算通过其他模态打开 ......

虽然它最初可能是“最简单的”,但它并没有建议甚至不支持(在某些情况下),并且就UX而言几乎不值得。这就像弹出式开头一样 - 实际上没有多少用例可以理解。

以下是一些值得一读的文章: