Div隐藏不工作

时间:2017-04-29 15:59:17

标签: javascript knockout-2.0

我正在尝试在未选中电子邮件复选框时隐藏代码。

<h4>{{ _('Email setup') }}</h4>
<form class="form-horizontal" id="enclosure_settings_email">
<div data-bind="foreach: global_settings.settings.plugins.enclosure.email_reading">
    <div class="control-group">
        <label class="checkbox">
            <input id="enableemail" type="checkbox" data-bind="click: $parent.emailUI()">  {{ _('Email Enable') }}
        </label> 
    </div>
    <div id="isEmailEnabled">
        <div class="control-group">
            <label class="control-label">{{ _('Email From') }}</label>
            <div class="controls">
                <input type="text" class="input-block-level" data-bind="value: emailFrom">
                <span class="help-inline">The addeess the email will come from</span>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label">{{ _('To Email') }}</label>
            <div class="controls">
                <input type="text" class="input-block-level" data-bind="value: emailTo">
                <span class="help-inline">The addeess the email will sent to</span>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label">{{ _('CC Email') }}</label>
            <div class="controls">
                <input type="text" class="input-block-level" data-bind="value: emailCC">
                <span class="help-inline">The addeess the email send copy to</span>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label">{{ _('SMTP Server') }}</label>
            <div class="controls">
                <input type="text" class="input-block-level" data-bind="value: emailServer">
                <span class="help-inline">The SMTP server to send email to:</span>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label">{{ _('SMTP Server Port') }}</label>
            <div class="controls">
                <input type="text" class="input-block-level" data-bind="value: emailPort">
                <span class="help-inline">The SMTP server Port</span>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label">{{ _('Send Image') }}</label>
            <div class="controls">   
                <input type="checkbox" data-bind="checked: include_snapshot">{{ _('Send Image') }}
                <span class="help-inline">To send image at the end of print job</span>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label">{{ _('SMTP SSL') }}</label>
            <div class="controls">
                <input id="emailSSL" type="checkbox" data-bind="click: $parent.emailsslUI()">  {{ _('Enable SSL') }}
                <span class="help-inline">The Enable SSL</span>
            </div>
        </div>
        <div id="isSSLEmailEnabled">
            <div class="control-group">
                <label class="control-label">{{ _('SMTP User Name') }}</label>
                <div class="controls">
                    <input type="text" class="input-block-level" data-bind="value: emailUser">
                    <span class="help-inline">Name to login SMTP</span>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">{{ _('SMTP Password') }}</label>
                <div class="controls">
                    <input type="password" class="input-block-level" data-bind="value: emailPassword"> 
                    <span class="help-inline">Password to login SMTP</span>
                </div>
            </div>
       </div> 
   </div>
</div>
<div id="isEmailEnable">
    <div class="control-group">
        <label class="control-label">{{ _('Send Test Email') }}</label>
        <div class="controls">
            <button data-bind="click: eventEmail">Test Email</button><p></p>
            <span class="help-inline">Send test email ckeck your email</span>
        </div>
    </div>
</div>

我有第一个div中的按钮可以查看/调用该功能或​​如何调用该功能? 我试过添加settings.plugins.enclosure等没有

     /**********************************************
    emailsslUI
    ***********************************************/
    self.emailsslUI = function(){
      if($('#emailSSL').is(':checked')){
         $('#isSSLEmailEnabled').show("blind");
      }else{
        $('#isSSLEmailEnabled').hide("blind");
      }
    };
    /**********************************************
    eventEmail
    ***********************************************/
    self.eventEmail = function(data,event) {
        $.ajax({
            type: "GET",
            url: "/plugin/enclosure/getEnclosureEmail",
            async: false
        });
    }
    /**********************************************

如何让它发挥作用?

1 个答案:

答案 0 :(得分:0)

我发现答案已删除了div,所以最后一分钟并添加了$ root。

<button data-bind="click: $root.eventEmail">Test Email</button><p></p>

如何正常工作