【问题标题】:Tooltip on the disabled div in angular js角度 js 中禁用 div 的工具提示
【发布时间】:2018-01-08 09:05:48
【问题描述】:

我是angularjs 的新手。实际上,在发布这个问题之前,我已经搜索了很多,我发现了这个问题的不同答案,但没有一个对我有用。所以,我也尝试了css。我在这里使用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>

现在在这段代码中我有一些变量,比如 -isSingleFileSelected 在此基础上我启用和禁用。现在我想要一个tooltip,即使它被禁用。所以,在这里我尝试在输入类型上添加ng-disabled,但用户可以点击该字段,它被禁用但仍然。所以,我在 div 本身上添加了ng-disabled,所以现在user is not able to click input type 但不是能够显示 to enable this do this 的工具提示。任何人都可以在这里帮助我。提前致谢。

【问题讨论】:

    标签: javascript jquery html css angularjs


    【解决方案1】:

    好的,这里有一个非常清楚的解释:

    在 javascript 中禁用的表单元素不会触发事件。

    这里最简单的解决方案是将输入标签包装在一个元素中,并在包装​​元素而不是 div 中显示工具提示。像这样的:

    <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>
    

    【讨论】:

    • 你是否在你的控制器中定义了 showTooltip 方法?
    • 实际显示工具提示的代码在哪里?了解我上面使用的 showTooltip 方法只是一个占位符。你必须在那里调用你的方法
    • 我写了一个返回字符串的方法
    • 无法聊天。办公室残疾人
    猜你喜欢
    • 1970-01-01
    • 2017-01-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-18
    相关资源
    最近更新 更多