Unable To Submit Form

Hello,

Trying to submit form with validation and upload files using efineuploader extension however after validate form and upload files i used this code


$('#jobs-form').submit();

for submit form but it’s not working…

it going to validate again and again

My Code:




<div class="form">  

    <?php

    $form = $this->beginWidget('CActiveForm', array(

        'id' => 'jobs-form',

        'enableAjaxValidation' => false,

        'enableClientValidation' => true,

        'clientOptions' => array(

            'validateOnSubmit' => true,

            'validateOnChange' => true,

            'afterValidate' => "js:function(form, data, hasError) {

                                if (hasError) {

                                    //alert('There were errors. Please correct them before submitting again.');

                                    return false; //<- normally not needed

                                } else {

                                    if($('.qq-upload-list li').length > 0) {

                                    //if there have file then upload files

                                        if($('.qq-upload-list li').length != $('.qq-upload-list li.qq-upload-success').length){

                                            //complete upload all files

                                            $('#submit_button').trigger('click'); 

                                        }

                                    } else {

                                        bootbox.confirm('Are you sure?', function(result) {

                                            //without file form submitt :: Issue to submit form

                                            if(result == true) {

                                                $('body').undelegate('#jobs-form', 'submit');

                                                $('#jobs-form').submit();

                                            }

                                        }); 

                                    }

                                }

                            }",

        ),

        'htmlOptions' => array(

            'class' => 'sr-form-horizontal',

        ),

    ));

    ?>

    <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12 padding-left-zero padding-right-zero">

        <?php echo $form->labelEx($model, 'staff_notes', array('class' => "col-lg-3 col-md-3 col-sm-12 col-xs-12 sr-control-label")); ?>

        <div class="col-lg-7 col-md-7 col-sm-12 col-xs-12">

            <?php echo $form->textArea($model, 'staff_notes', array('class' => 'form-control')); ?>

            <?php echo $form->error($model, 'staff_notes'); ?>

        </div>

    </div>

    <?

    $this->widget('ext.EFineUploader.EFineUploader', array(

        'id' => 'uploader',

        'config' => array(

            'autoUpload' => false,

            'editFilename' => array(

                'enabled' => true

            ),

            'text' => array('uploadButton' => '<i class="icon-sr-icons-add"></i> Add Files'),

            'multiple' => true,

            'request' => array(

                'endpoint' => '/compliance/upload', // OR $this->createUrl('controller/upload'),

                'params' => array('YII_CSRF_TOKEN' => Yii::app()->request->csrfToken),

            ),

            'retry' => array('enableAuto' => true, 'preventRetryResponseProperty' => true),

            'chunking' => array('enable' => true, 'partSize' => 100), //bytes

            'callbacks' => array(

                'onComplete' => "js:function(id, name, response){

                                docids.push(response.document_id);

                                if($('.qq-upload-list li').length == $('.qq-upload-list li.qq-upload-success').length) {

                                    //that means uploaded all files  :: Issue to submit form

                                    $('#docids').val(docids.join(','));

                                    $('#jobs-form').submit();

                                }

                            }",

            ),

            'validation' => array(

                'allowedExtensions' => array('jpg', 'jpeg', 'doc', 'zip', 'pdf', 'xls', 'docx', 'xlsx', 'txt'),

                'sizeLimit' => 100 * 1024 * 1024, //maximum file size in bytes

            ),

        )

    ));

    ?>

    <?php echo CHtml::hiddenField('docids'); ?>

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

</div>



please advice how to submit form after validate above code