Attribuire Jquery Ad Un Oggetto Button

continua a non funzionare il widget :(

puoi passarmi qualcosa di più della tua view?

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>

hai provato a mettere il codice che ti ho dato?

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

si, sucsa se te l’ho chiesto, ma ho visto che la view ha il codice vecchio.

ci lavoro e poi ti dico

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)