简体   繁体   English

angular js中禁用div的工具提示

[英]Tooltip on the disabled div in angular js

I am new to angularjs . 我是angularjs Actually before posting this question I have searched a lot I found different answers for the question, but none of that were working for me . 实际上,在发布此问题之前,我已经进行了很多搜索,发现该问题的答案不同,但是没有一个对我有用。 So, I tried with the css as well. 因此,我也尝试使用CSS。 Here I am using a input type="file" and for that My code is like - 在这里,我使用input type="file" ,为此,我的代码就像-

<div class="btn btn-info btn-labeled file-preview-input" ng-disabled="isSingleFileSelected">
                                <span class="glyphicon glyphicon-folder-open"></span>
                        <span class="file-preview-input-title">BrowseFolder</span>
                         <input type="file" ng-click="clearFileName()" id="uploadId" webkitdirectory directory multiple file-upload="myFile" accept=".txt, .rtf, .pdf, .doc, .docx, .rtx, .odt, .sxw, .wpd, .odf"
                                name="input-file-preview" />
                    </div>
                    <div class="btn btn-info btn-labeled file-preview-input" ng-disabled="isFolderSelected">
                        <span class="glyphicon glyphicon-file"></span>
                        <span class="file-preview-input-title">BrowseFile</span>
                        <input type="file" ng-click="clearFileName()" file-upload="myFile" accept=".txt, .rtf, .pdf, .doc, .docx, .rtx, .odt, .sxw, .wpd, .odf" name="input-file-preview"
                        />
                    </div>

Now in this code I have some variables like - isSingleFileSelected on that basis I am enabling and disabling . 现在在这段代码中,在启用和禁用的基础上,我有一些变量isSingleFileSelected Now I want to have a tooltip even if it is disabled . 现在,我希望有一个tooltip即使它已被禁用。 So, Here I tried by adding the ng-disabled on the input type but there user is able to click on that field,it is disabled but still.So, I added ng-disabled on the div itself so now user is not able to click input type but not able to show the tooltip that to enable this do this . 所以,在这里我尝试通过在输入类型上添加ng-disabled ,但是用户可以单击该字段,但它仍然被禁用。所以,我在div本身上添加了ng-disabled ,所以现在user is not able to click input type但无法显示to enable this do this的工具提示。 Can any one please help me here. 任何人都可以在这里帮助我。 Thanks in advance. 提前致谢。

Ok so here is a very clear explanation: 好的,这是一个非常清晰的解释:

Events are not fired on disabled form elements in javascript. 不会在javascript中禁用的表单元素上触发事件。

The easiest solution here is to wrap your input tag in an element, and show your tooltip in the wrapping element instead of the div. 这里最简单的解决方案是将输入标签包装在一个元素中,并在包装​​元素中显示您的工具提示,而不是在div中显示。 Something like this: 像这样:

<div class="btn btn-info btn-labeled file-preview-input" ng-disabled="isSingleFileSelected">
       <span class="glyphicon glyphicon-folder-open"></span>
       <span class="file-preview-input-title">BrowseFolder</span>
       <div ng-mouseover="showTooltip()">
           <input type="file" ng-click="clearFileName()" id="uploadId" webkitdirectory directory multiple file-upload="myFile" accept=".txt, .rtf, .pdf, .doc, .docx, .rtx, .odt, .sxw, .wpd, .odf" name="input-file-preview" />
       </div>
</div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM