0

I have done a yiibooster wizard form, everything works perfectly BUT i want to force the customer to click in a TbExtendedGridView before he can do the next step.

In the form there are 2 TbExtendedGridView and 2 date fields.

Here is some code of the form:

    <?php $form=$this->beginWidget('bootstrap.widgets.TbActiveForm', array(
    'id'=>'zf-contratos-form',
    // Please note: When you enable ajax validation, make sure the corresponding
    // controller action is handling ajax validation correctly.
    // There is a call to performAjaxValidation() commented in generated controller code.
    // See class documentation of CActiveForm for details on this.
    'enableAjaxValidation'=>false,
    'htmlOptions'=>array('class'=>'well'),
    'action' => array( '/ZfContratos/create' ),
)); ?>
    <div id="wizard-bar" class="progress progress-striped active">
    <div class="bar"></div>
    </div>
    <?php $this->widget(
    'bootstrap.widgets.TbWizard',
    array(
        'type' => 'tabs', // 'tabs' or 'pills'
        'pagerContent' => '<div style="float:right">
                    <input type="button" class="btn button-next" name="next" value="Siguiente" />
                </div>
                <div style="float:left">
                    <input type="button" class="btn button-previous" name="previous" value="Atrás" />
                </div>
                <br /><br />',
        'options' => array(
            'nextSelector' => '.button-next',
            'previousSelector' => '.button-previous',
            'onTabShow' => 'js:function(tab, navigation, index) {
                        var $total = navigation.find("li").length;
                        var $current = index+1;
                        var $percent = ($current/$total) * 100;
                        $("#wizard-bar > .bar").css({width:$percent+"%"});
            }',
            'onTabClick' => 'js:function(tab, navigation, index) {alert("Tab Click Disabled");return false;}',
        ),
        'tabs' => array(
            array(
                'label' => 'Arrendatarios',
                'content' => $this->renderPartial('//ZfContratos/_form_arrendatarios', array('model' => $model, 'form' => $form), true),
                'active' => true
            ),
            array('label' => 'Inmuebles', 'content' => $this->renderPartial('//ZfContratos/_form_inmuebles', array('model' => $model, 'form' => $form), true)),
            array('label' => 'Fecha', 'content' => $this->renderPartial('//ZfContratos/_form_contratos', array('model' => $model, 'form' => $form), true)),
        ),
    )
); ?>

<?php $this->endWidget(); ?>

The procedure would be, first step with "next" disable and when the customer clik on a row of the TbExtendedGridView "next" will be available and he can click on "next" to the next step.

Thank you so much.

CODE TESTED WORKING:

$cs = Yii::app()->getClientScript();
$cs->registerScript('hello', "
    $(window).load(function()
    { 
        alert('hello');
        $('#next').attr('disabled',true);
    });");
$cs->registerScript('button',"
        $('#arrendatario').click(function() 
        {
            $('#next').attr('disabled',false);
    });");
4

1 回答 1

0

您可以在 Jquery 中执行此操作。首先你必须设置 Id of TbExtendedGridView。下一个按钮包含类next然后你这样做

<script type="text/javascript">
window.onload=function(){
$('.next').attr('disabled',true);
}
$(document).ready(
function()
{
   $('.grid-view').click(function() 
{
   $('.next').attr('disabled',false);
});
}
);
</script>

我已将类用作选择器,但您可以将使用 ID 作为选择器用作“#selector”。您还可以在grid-view. 以上只是一个例子。
这是一些关于 jquery 选择器的信息
http://www.w3schools.com/jquery/jquery_ref_selectors.asp

编辑: 试试

   <?php $cs = Yii::app()->getClientScript();
$cs->registerScript('hello', "
$(window).load(function()
{ 
    alert('hello');
}
)");
?>

如果可行,则复制此脚本中的整个代码。

于 2014-02-10T16:15:02.190 回答