Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Yii2:如何制作a<;部门>;使用jQuery禁用/只读_Jquery_Yii2_Disabled Input_Readonly Attribute - Fatal编程技术网

Yii2:如何制作a<;部门>;使用jQuery禁用/只读

Yii2:如何制作a<;部门>;使用jQuery禁用/只读,jquery,yii2,disabled-input,readonly-attribute,Jquery,Yii2,Disabled Input,Readonly Attribute,我需要在Yii2框架下禁用或将的图标设为只读 datepicker小部件有两部分:图标的和日期的。我可以使用jQuery禁用,但无法禁用 这是jQuery代码: $("#movements-vencimiento").prop("disabled", true); // Works. $("#vencimientoDiv").prop("disabled", true) // Not works. 这是Yii2代码: <div class="col col-md-4" id="venc

我需要在Yii2框架下禁用或将的图标设为只读

datepicker小部件有两部分:图标的
和日期的
。我可以使用jQuery禁用
,但无法禁用

这是jQuery代码:

$("#movements-vencimiento").prop("disabled", true); // Works.
$("#vencimientoDiv").prop("disabled", true) // Not works.
这是Yii2代码:

<div class="col col-md-4" id="vencimientoDiv">
    <?= $form->field($model, 'vencimiento')->widget(\common\widgets\DatePicker::className(), [
        'convertFormat' => true,
        'pluginOptions' => [
            'format' => 'dd/mm/yyyy',
            'autoclose' => true,
            'language' => 'es-AR',
            'todayHighlight' => 'true',
        ]
    ]) ?>
</div>

这是HTML生成的代码:

<div id="vencimientoDiv">
    <div class="form-group field-movements-vencimiento">
        <label class="control-label" for="movements-vencimiento">Vencimiento</label>
        <div class="input-group date">
            <span class="input-group-addon">
                <i class="fa fa-calendar"></i>
            </span>
            <input type="text" id="movements-vencimiento" class="form-control" name="Movements[vencimiento]" disabled="">
        </div>
        <div class="help-block"></div>
    </div>
</div>

文西米恩托

div没有禁用的
属性。相反,您可以删除导致日历显示的事件处理程序,如下所示:

$("#vencimientoDiv *").off();

就这么简单。

您要寻找的是适用于所有元素的
pointerEvents
,您可以在需要时禁用和启用“单击返回”

请参阅下面的一个简单演示

$(“#clicker”)。在('click',函数(e){
e、 预防默认值();
警报(“点击”);
});
$(“#disab”)。在('click',function()上{
$(“#点击器”).css({
pointerEvents:“无”
});
})
$(“#enab”)。在('click',function()上{
$(“#点击器”).css({
pointerEvents:“自动”
});
})