【问题标题】:Cakephp 2.X disable/enable syntaxCakephp 2.X 禁用/启用语法
【发布时间】:2017-08-30 15:06:12
【问题描述】:

我正在使用以下示例 http://jsfiddle.net/nc6NW/1/

然而,当我将其更改为 formhelper 语法时,Jquery 不会重新启用禁用的保存功能。鉴于此功能,如何删除此属性

<div id="newArticleForm">
    <?php
    echo $this->Form->create('Post', array('action' => 'add'));
    echo $this->Form->input('article_title',array('type' => 'text', 'id'=>'ArticleHeader','div'=>false,'label'=>false,'class'=>'centertext',"placeholder"=>"Article Header"));
    echo $this->Html->para(null,'<br>', array());
    echo $this->Form->input('article_link',array('type' => 'text', 'id'=>'ArticleLink','div'=>false,'label'=>false,'class'=>'centertext',"placeholder"=>"Article Link"));
    echo $this->Html->para(null,'<br>', array());
    echo $this->Form->button('Cancel', array('type' => 'reset'), array('inline' => false));
    echo $this->Form->button('Save', array('type' => 'submit', 'disabled'=>true), array('inline' => false));

    echo $this->Form->end();
    ?>
</div>
<script>
$(':text').keyup(function() {
    if($('#ArticleHeader').val() != "" && $('#ArticleLink').val() != "") {
        $('#submit').removeAttr('disabled');
    } else {
        $('#submit').attr('disabled', true);
    }
});
</script>

【问题讨论】:

    标签: php jquery html cakephp cakephp-2.x


    【解决方案1】:

    已解决,抱歉浪费大家时间 submit 有错误的标识符,需要冒号而不是哈希。 即

    $(':text').keyup(function() {
        if($('#ArticleHeader').val() != "" && $('#ArticleLink').val() != "") {
            $(':submit').removeAttr('disabled');
        } else {
            $(':submit').attr('disabled', true);
        }
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-01
      • 2019-10-31
      • 1970-01-01
      • 2017-08-12
      • 1970-01-01
      相关资源
      最近更新 更多