Yii Framework Forum: update model with cjuidialog from dropdownlist - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

update model with cjuidialog from dropdownlist Rate Topic: -----

#1 User is offline   trikkadeeri 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 06-August 11

Posted 30 July 2012 - 10:57 PM

I'm following the super wiki of Zaccaria http://www.yiiframew...eate-new-model/ to create a new model using cjuidialog. Great ideas are always simple, no? Thank you Zaccaria!!

I'm trying to follow Russel England's wiki here to update a model, but from a dropdownlist:

Here is the form:

echo $form->dropDownList($model, 'complainant_id', CHtml::listData(Complainant::model()->findAll($criteria), 'id', 'full_name'),
                array('prompt' => 'Select',
                    'style' => "width: 300px;",
                    'onchange' => '{                    
                    showComplainant._showComplainant_url="'.Yii::app()->createUrl("complainant/ajaxupdate", array("id"=>$model->complainant_id)).'";

And this is the javascript function:
<script type="text/javascript">
                // here is the magic
                function showComplainant()
                    // public property                    
                    var _showComplainant_url;
                    <?php echo CHtml::ajax(array(
                        'url' => 'js:showComplainant._showComplainant_url',
                        'data' => "js:$(this).serialize()",
                        'type' => 'post',
                        'dataType' => 'json',
                        'success' => "function(data)
                            if (data.status == 'failure')
                                $('#dialogShowComplainant div.divComplainantShow').html(data.div);                                
                                // Here is the trick: on submit-> once again this function!
                                $('#dialogShowComplainant div.divComplainantShow form').submit(showComplainant);
                                $('#dialogShowComplainant div.divComplainantShow').html(data.div);
                    return false;

But it does not work.

From Firebug console I can see that '$model->complainant_id' remains empty and the GET 'id' with the url has no value.

When I try 'this.value' as a parameter to showComplainant(), the selected value gets passed on to the javascript function.

But then, the problem faced by Russel England, as given in his post that led to his wiki article, crops up in my case also.

Can't figure out why '$model->complainant_id' remains empty at 'onchange' event of dropdownlist.

Please help!!

Share this topic:

Page 1 of 1
  • 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