Yii Framework Forum: Attribuire Jquery Ad Un Oggetto Button - Yii Framework Forum

Jump to content

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

Attribuire Jquery Ad Un Oggetto Button Rate Topic: -----

#21 User is offline   michele 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 221
  • Joined: 02-August 12

Posted 15 October 2012 - 09:21 AM

continua a non funzionare il widget :(
0

#22 User is offline   emafer 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 182
  • Joined: 23-February 12
  • Location:Amandola

Posted 15 October 2012 - 12:05 PM

puoi passarmi qualcosa di più della tua view?
0

#23 User is offline   michele 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 221
  • Joined: 02-August 12

Posted 16 October 2012 - 03:27 AM

farò di più te la passo tutta :D

<div class="form">
<?php /* Yii::app()->clientScript->registerScript('hide_div','
count_widget=0;
$("#sel_prodotto").hide();
',  CClientScript::POS_HEAD);*/
Yii::app()->clientScript->registerScript('hide_div','
count_widget=0;
$("#sel_prodotto").hide();
',  CClientScript::POS_READY);

$script='function aggiungiwidget(){
////clono il widget
nuovowidget=$("#sel_prodotto").clone();
nuovowidget.attr("id","agg_prodotto_"+count_widget);
////aumento il counter
count_widget=count_widget+1;
////lo aggiungi
$("#prodotto").append(nuovowidget);
nuovowidget.show();
}';

Yii::app()->clientScript->registerScript('aggiungiwidget',$script,  CClientScript::POS_HEAD);
?>
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'rich_accettazione-form',
	'enableAjaxValidation'=>true,
        'clientOptions'=>array(
		'validateOnSubmit'=>true,
            ),
)); ?>
	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php 

        $form->errorSummary($model_clienti_p); 
            ?>

	<div class="row">
		<?php echo $form->labelEx($model_clienti_p,'id_produttore'); ?>
            
                <?php if(Yii::app()->user->group == 'Admin_Accettazione'){
                        echo "ciao";?>
		<?php $form->widget('ext.combobox.EJuiComboBox', array(
                     'model'=>$model_clienti_p,
                     'attribute' => 'id_produttore',
                     // data to populate the select. Must be an array.
                     'data' => ClientiProduttoriController::lista_pro_combobox(),
                     // options passed to plugin
                     'options' => array(
                        // JS code to execute on 'select' event, the selected item is
                        // available through the 'item' variable.
                        'onSelect' => '',
                        // JS code to be executed on 'change' event, the input is available
                        // through the '$(this)' variable.
                        'onChange' => '',
                        // If false, field value must be present in the select.
                        // Defaults to true.
                        'allowText' => TRUE,
                    ),
                    // Options passed to the text input
                    'htmlOptions' => array('size' => 10),
                ));
               ?>   
                    <?php } else { 
                        echo $form->textField($model_clienti_p,'id_produttore');                        
                    }
?>
		<?php echo $form->error($model_clienti_p,'id_produttore'); ?>
	</div>

        
	<div id="prodotto" class="row">
                
		<?php echo $form->labelEx($model_prodotto,'Nome Prodotto'); ?>
            
                <?php $form->widget('ext.combobox.EJuiComboBox', array(
                     'model' => $model_prodotto,
                     'attribute' => 'nome_prodotto',
                     // data to populate the select. Must be an array.
                     'data' => ProdottoController::lista_pro_combobox(),
                     // options passed to plugin
                     'options' => array(
                        // JS code to execute on 'select' event, the selected item is
                        // available through the 'item' variable.
                        'onSelect' => '',
                        // JS code to be executed on 'change' event, the input is available
                        // through the '$(this)' variable.
                        'onChange' => '',
                        // If false, field value must be present in the select.
                        // Defaults to true.
                        'allowText' => TRUE,
                    ),
                    // Options passed to the text input
                    'htmlOptions' => array(
                    'size' => 10
                    ,'id'=> 'nome_prodotto'
                    ),
                ));
               ?> 
             <?php echo $form->error($model,'nome_prodotto'); ?>  
            <?php echo $form->labelEx($model,'quantita_iniziale'); ?>
		<?php echo $form->textField($model,'quantita_iniziale'); ?>
		<?php echo $form->error($model,'quantita_iniziale'); ?>
	
        </div>
          <?php echo CHtml::button('Aggiungi prodotto',array('onclick'=>' aggiungiwidget();'                                                                             
                                                                                                                                              
                                                                  )); 
                ?>
     
       	<div class="row buttons">  
                <?php 
                         echo CHtml::ajaxSubmitButton('Invia_richiesta' , 
                                  CHtml::normalizeUrl(array('accettazione/CalcoloNumAccettazione')),array(                                                                                                          
                                                                                                          //'data'=>array('count'=>'js:count_widget','form'=>'js:$("#rich_accettazione-form").serialize()'),
                                                                                                          'beforeSend'=>'function(){ $(\'#col_des\').html(\'<img src='.Yii::app()->request->baseUrl."/images/loading.gif".'>\'); }' ,
                                                                                                          'success'=>'function(data){$(\'#col_des\').html(data);}'                                                                                                          
                                                                                                         )
                                                                                                        );       
		?>
	</div>

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

</div><!-- form -->

<div id="sel_prodotto">
                <?php 
             $form->widget('ext.combobox.EJuiComboBox', array(
                 'model' => $model_prodotto,
                      // data to populate the select. Must be an array.
                    'attribute' => 'nome_prodotto',
                     // data to populate the select. Must be an array.
                     'data' => ProdottoController::lista_pro_combobox(),
                     // options passed to plugin
                      'options' => array(
                        // JS code to execute on 'select' event, the selected item is
                        // available through the 'item' variable.
                        'onSelect' => '',
                        // JS code to be executed on 'change' event, the input is available
                        // through the '$(this)' variable.
                        'onChange' => '',
                        // If false, field value must be present in the select.
                        // Defaults to true.
                        'allowText' => TRUE,
                    ),
                    // Options passed to the text input
                    'htmlOptions' => array(
                    'size' => 10
                     ,'id'=> 'id_da_cambiare'
                     ),
                 ));
               ?> 
</div>

0

#24 User is offline   emafer 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 182
  • Joined: 23-February 12
  • Location:Amandola

Posted 16 October 2012 - 03:39 AM

hai provato a mettere il codice che ti ho dato?
0

#25 User is offline   michele 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 221
  • Joined: 02-August 12

Posted 16 October 2012 - 04:59 AM

si si purtroppo sempre lo stesso risultati , con il tuo andava solomente ad inserire il value , ma a me non interessa quello ma che m carichi il widget
0

#26 User is offline   emafer 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 182
  • Joined: 23-February 12
  • Location:Amandola

Posted 16 October 2012 - 06:22 AM

si, sucsa se te l'ho chiesto, ma ho visto che la view ha il codice vecchio.
ci lavoro e poi ti dico
0

#27 User is offline   michele 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 221
  • Joined: 02-August 12

Posted 16 October 2012 - 08:45 AM

ok grazie, comunque ho trovato una soluzione temporanea non molto efficace ma funziona ovvero.

<div class="form">
<?php /* Yii::app()->clientScript->registerScript('hide_div','
count_widget=0;
$("#sel_prodotto").hide();
',  CClientScript::POS_HEAD);*/
Yii::app()->clientScript->registerScript('hide_div','
count_widget=0;
$("#prodotto_1").hide();
$("#prodotto_2").hide();
',  CClientScript::POS_READY);


//$script='function aggiungiwidget(){
////clono il widget
//nuovowidget=$("#nome_prodotto").clone();
//nuovowidget.attr("id","agg_prodotto_"+count_widget);
////aumento il counter
//count_widget=count_widget+1;
////lo aggiungi
//$("#prodotto").append(nuovowidget);
////nuovowidget.show();
//}';
$script='function aggiungiwidget(){
count_widget=count_widget+1; 
$("#prodotto_"+count_widget).show();
}
';
Yii::app()->clientScript->registerScript('aggiungiwidget',$script,  CClientScript::POS_HEAD);
?>
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'rich_accettazione-form',
	'enableAjaxValidation'=>true,
        'clientOptions'=>array(
		'validateOnSubmit'=>true,
            ),
)); ?>
	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php 

        $form->errorSummary($model_clienti_p); 
            ?>

	<div class="row">
		<?php echo $form->labelEx($model_clienti_p,'id_produttore'); ?>
            
                <?php if(Yii::app()->user->groupName == 'Admin_Accettazione'){?>
		<?php $form->widget('ext.combobox.EJuiComboBox', array(
                     'model'=>$model_clienti_p,
                     'attribute' => 'id_produttore',
                     // data to populate the select. Must be an array.
                     'data' => ClientiProduttoriController::lista_idPro_combobox(),
                     // options passed to plugin
                     'options' => array(
                        // JS code to execute on 'select' event, the selected item is
                        // available through the 'item' variable.
                        'onSelect' => '',
                        // JS code to be executed on 'change' event, the input is available
                        // through the '$(this)' variable.
                        'onChange' => '',
                        // If false, field value must be present in the select.
                        // Defaults to true.
                        'allowText' => TRUE,
                    ),
                    // Options passed to the text input
                    'htmlOptions' => array('size' => 10),
                ));
               ?>   
                    <?php } else { 
                        echo $form->textField($model_clienti_p,'id_produttore');                        
                    }
?>
		<?php echo $form->error($model_clienti_p,'id_produttore'); ?>
	</div>

        
	<div id="prodotto" class="row">
                
		<?php echo $form->labelEx($model_prodotto,'Nome Prodotto'); ?>
            
                <?php $form->widget('ext.combobox.EJuiComboBox', array(
                     'model' => $model_prodotto,
                     'attribute' => 'nome_prodotto',
                     // data to populate the select. Must be an array.
                     'data' => ProdottoController::lista_pro_combobox(),
                     // options passed to plugin
                     'options' => array(
                        // JS code to execute on 'select' event, the selected item is
                        // available through the 'item' variable.
                        'onSelect' => '',
                        // JS code to be executed on 'change' event, the input is available
                        // through the '$(this)' variable.
                        'onChange' => '',
                        // If false, field value must be present in the select.
                        // Defaults to true.
                        'allowText' => TRUE,
                    ),
                    // Options passed to the text input
                    'htmlOptions' => array(
                    'size' => 10
                    ,'id'=> 'nome_prodotto'
                    ),
                ));
               ?> 
             <?php echo $form->error($model,'nome_prodotto'); ?>  
            <?php echo $form->labelEx($model,'quantita_iniziale'); ?>
		<?php echo $form->textField($model,'quantita_iniziale'); ?>
		<?php echo $form->error($model,'quantita_iniziale'); ?>
        
            
            <div id="prodotto_1">
                <?php echo $form->labelEx($model_prodotto,'Nome del secondo Prodotto'); ?>
                <?php $form->widget('ext.combobox.EJuiComboBox', array(
                     'model' => $model_prodotto,
                     'attribute' => 'nome_prodotto1',
                     // data to populate the select. Must be an array.
                     'data' => ProdottoController::lista_pro_combobox(),
                     // options passed to plugin
                     'options' => array(
                        // JS code to execute on 'select' event, the selected item is
                        // available through the 'item' variable.
                        'onSelect' => '',
                        // JS code to be executed on 'change' event, the input is available
                        // through the '$(this)' variable.
                        'onChange' => '',
                        // If false, field value must be present in the select.
                        // Defaults to true.
                        'allowText' => TRUE,
                    ),
                    // Options passed to the text input
                    'htmlOptions' => array(
                    'size' => 10
                    ,'id'=> 'nome_prodotto_1',
                    ),
                ));
               ?> 
            
             <?php echo $form->error($model,'nome_prodotto1'); ?>  
            <?php echo $form->labelEx($model,'quantita_iniziale1'); ?>
		<?php echo $form->textField($model,'quantita_iniziale1'); ?>
		<?php echo $form->error($model,'quantita_iniziale1'); ?>
            </div>
            
            <div id="prodotto_2">
                <?php echo $form->labelEx($model_prodotto,'Nome del Primo Prodotto'); ?>
                <?php $form->widget('ext.combobox.EJuiComboBox', array(
                     'model' => $model_prodotto,
                     'attribute' => 'nome_prodotto2',
                     // data to populate the select. Must be an array.
                     'data' => ProdottoController::lista_pro_combobox(),
                     // options passed to plugin
                     'options' => array(
                        // JS code to execute on 'select' event, the selected item is
                        // available through the 'item' variable.
                        'onSelect' => '',
                        // JS code to be executed on 'change' event, the input is available
                        // through the '$(this)' variable.
                        'onChange' => '',
                        // If false, field value must be present in the select.
                        // Defaults to true.
                        'allowText' => TRUE,
                    ),
                    // Options passed to the text input
                    'htmlOptions' => array(
                    'size' => 10
                    ,'id'=> 'nome_prodotto_2',
                    ),
                ));
               ?> 
            
               <?php echo $form->error($model,'nome_prodotto2'); ?>
               <?php echo $form->labelEx($model,'quantita_iniziale2'); ?>
		<?php echo $form->textField($model,'quantita_iniziale2'); ?>
		<?php echo $form->error($model,'quantita_iniziale2'); ?>
             </div>
	
        </div>
          <?php echo CHtml::button('Aggiungi prodotto',array('onclick'=>' aggiungiwidget();'                                                                             
                                                                                                                                              
                                                                  )); 
                ?>
     
       	<div class="row buttons">  
                <?php 
                         echo CHtml::ajaxSubmitButton('Invia_richiesta' , 
                                  CHtml::normalizeUrl(array('accettazione/CalcoloNumAccettazione')),array(                                                                                                          
                                                                                                          //'data'=>array('count'=>'js:count_widget','form'=>'js:$("#rich_accettazione-form").serialize()'),
                                                                                                          'beforeSend'=>'function(){ $(\'#col_des\').html(\'<img src='.Yii::app()->request->baseUrl."/images/loading.gif".'>\'); }' ,
                                                                                                          'success'=>'function(data){$(\'#col_des\').html(data);}'                                                                                                          
                                                                                                         )
                                                                                                        );       
		?>
	</div>

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

</div><!-- form -->

<div id="sel_prodotto">
                <?php 
 //               $form->widget('ext.combobox.EJuiComboBox', array(
 //                    'model' => $model_prodotto,
                      // data to populate the select. Must be an array.
  //                   'attribute' => 'nome_prodotto',
                     // data to populate the select. Must be an array.
   //                   'data' => ProdottoController::lista_pro_combobox(),
                     // options passed to plugin
    //                  'options' => array(
                        // JS code to execute on 'select' event, the selected item is
                        // available through the 'item' variable.
   //                      'onSelect' => '',
                        // JS code to be executed on 'change' event, the input is available
                        // through the '$(this)' variable.
      //                   'onChange' => '',
                        // If false, field value must be present in the select.
                        // Defaults to true.
     //                    'allowText' => TRUE,
    //                 ),
                    // Options passed to the text input
   //                  'htmlOptions' => array(
  //                   'size' => 10
    //                 ,'id'=> 'id_da_cambiare'
    //                 ),
   //              ));
               ?> 
</div>


ovvero precaricare il widget e nasconderlo ed al click renderlo visibile(ne ho fatti 2)
0

Share this topic:


  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users