简体   繁体   English

为什么这个输入类型=“checkbox”标签的html模式用于破坏ngx-bootstrap模式对话框

[英]Why is this html pattern of input type="checkbox" lable for breaking the ngx-bootstrap modal dialog

icheck-bootstrap is a pure css checkboxes and radio buttons for Twitter bootstrap. icheck-bootstrap 是 Twitter 引导程序的纯 css 复选框和单选按钮。 This implies it will work with any of the frontend libraries.这意味着它将与任何前端库一起使用。 At least that's the way I figured it... And indeed, his use from the readme of his github page for the library : Link to icheck-bootstrap demo with docs Does work it just has a side effect that I can live with.至少我是这么认为的……事实上,他从他的 github 页面的自述文件中使用了库:链接到 icheck-bootstrap 演示和文档确实有效,它只是有一个我可以忍受的副作用。

In at lease one place where I'm trying to use this library, the component is in a modal dialog that is used to login to the site.在我尝试使用该库的至少一个地方,该组件位于用于登录站点的模式对话框中。 Below is the html template code for the component:下面是组件的html模板代码:

    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close" aria-hidden="true" (click)="hideModal()">
            <span aria-hidden="true">&times;</span>
        </button>
        <h3 class="modal-title-site text-center"> Login to Rove </h3>
    </div>
    <form #f="ngForm" (ngSubmit)="onSubmit()">
        <div class="modal-body">
            <div class="form-group login-username">
                <div>
                    <input name="log" id="login-user" class="form-control input" size="20"
                            [(ngModel)]="model.email" placeholder="Enter User Email" type="email">
                </div>
            </div>
            <div class="form-group login-password">
                <div>
                    <input name="Password" id="login-password" class="form-control input" size="20"
                            [(ngModel)]="model.password" placeholder="Password" type="password">
                </div>
            </div>
            <div class="col-lg-12">
                <div class="form-group">
                    <span class="checkbox login-remember">
                        <input name="rememberme" value="forever" checked="checked" 
                                [(ngModel)]="model.rememberMe" type="checkbox">
                        <label for="rememberme">Remember Me</label>
                    </span>
                </div>
            </div>
            <div>
                <div>
                    <input name="submit" class="btn  btn-block btn-lg btn-primary" value="LOGIN" type="submit">
                </div>
            </div>

        </div>
    </form>
    <div class="modal-footer">
        <p class="text-center">
            Not here before? <a data-toggle="modal" data-dismiss="modal"
                                href="#ModalSignup">Sign Up.</a> <br>
            <a href="forgot-password.html"> Lost your password? </a>
        </p>
    </div>

The code above is without the icheck-bootstrap implemented code.上面的代码没有 icheck-bootstrap 实现的代码。 Below I have changed the key lines of code that will implement the checkbox as per the readme documention on the github site下面我根据github站点上的自述文件更改了将实现复选框的关键代码行

    <div class="icheck-success checkbox login-remember">
        <input id="rememberme" value="forever" checked="checked" 
                [(ngModel)]="model.rememberMe" type="checkbox">
        <label for="rememberme">Remember Me</label>
    </div>

this code works as per the readme, unfortunately, after the dialog has been closed the modality of the modal dialog stays and the main page behind it will not allow any input from keyboard or mouse.不幸的是,此代码按照自述文件工作,在对话框关闭后,模态对话框的模态保持不变,其后面的主页将不允许来自键盘或鼠标的任何输入。

Note the input tag in the effective lines, I have change from the name attribute, to the id attribute.请注意有效行中的输入标记,我已从 name 属性更改为 id 属性。 That seems wrong to me but, it is as the documentation suggests and, the only way it will completely work.这对我来说似乎是错误的,但是,正如文档所建议的那样,这是它完全起作用的唯一方法。 If I do not change the attribute from name to id the checkbox changes to the correct style but it will not check to show a true state.如果我不将属性从 name 更改为 id 复选框更改为正确的样式,但它不会检查以显示真实状态。 In fact if I remove the icheck-success class from the class attribute of the above div line the behavior is identical and the component will still not take input after the dialog box has been closed if I use the id attribute instead of the name attribute.事实上,如果我从上面 div 行的 class 属性中删除 icheck-success 类,行为是相同的,如果我使用 id 属性而不是 name 属性,则在对话框关闭后组件仍不会接受输入。

I'm using Angular V9 and the dialog component that I am using is from the Valor Software ngx-bootstrap library and, as stated, it works perfectly when I code the html input tag with the name attribute.我使用的是 Angular V9,我使用的对话框组件来自 Valor Software ngx-bootstrap 库,如上所述,当我使用 name 属性对 html 输入标签进行编码时,它工作得很好。 Does any know of a workaround or possibly what is happening here?有没有人知道解决方法或可能这里发生了什么? the styling is what I want on the site but not at the cost of not having the login dialog effectively lock the site up after you login.样式是我在网站上想要的,但不是以登录对话框有效地在您登录后锁定网站为代价。

Thanks for any info that you may have on this issue.感谢您提供有关此问题的任何信息。

I have fix the problem I was having.我已经解决了我遇到的问题。 The first part of the problem was that I was not asking the right question.问题的第一部分是我没有问正确的问题。 I have edited the question to ask it in a better way, I think.我已经编辑了这个问题,以更好的方式提问,我想。

I have fixed the problem with the html below:我已经解决了以下 html 的问题:

    <div class="icheck-success checkbox login-remember">
        <input id="rememberme" name="rememberme" [(ngModel)]="model.rememberMe" type="checkbox">
        <label for="rememberme">Remember Me</label>
    </div>

it seems I had to have a name attribute in the input tag for some reason that I'm not clear about at all but, this is what I did to get the modal dialog to truly clear from the page after close.似乎由于某种原因我必须在 input 标签中有一个 name 属性,我根本不清楚,但是,这是我所做的,以使模式对话框在关闭后真正从页面中清除。

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

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