Yii - How Can I Call A Script From Ejuicombobox Widget

I’m not able to call the javascript from a Yii widget.

Below is the script :




    <script>

    var removed;

    

    $('#min').change( function() {

        var value = this.value;

        console.log("value",value);

        $('#max').prepend(removed);

        var toKeep = $('#max option').filter( function( ) {

            return parseInt(this.value) >= parseInt( value);

        } );

        removed =  $('#max option').filter( function( ) {

            return parseInt(this.value) < parseInt( value);

        } );

        $('#max').html(toKeep);

    });

    </script>



When I use this, it is not working. How can i call this script from widget

Below is the Yii widget used :


  


     <?php 

        $this->widget('ext.combobox.EJuiComboBox', array(

            'model' => $model,

            'attribute' => 'min',

            'data' => Yii::app()->params['cost_min_resales'],

            'options' => array(

                

                'allowText' => false,

            ),     

            'htmlOptions' => array('placeholder' => 'Min Cost', 'style'=>'width:70px'),

        ));

        ?>

    <?php 

        $this->widget('ext.combobox.EJuiComboBox', array(

            'model' => $model,

            'attribute' => 'max',

            'data' => Yii::app()->params['cost_min_resales'],

            'options' => array(

                

                'allowText' => false,

            ),     

            'htmlOptions' => array('placeholder' => 'Min Cost', 'style'=>'width:70px'),

        ));

        ?>




you may use onload in htmlOptions.

[b]

[/b]

like,

‘htmlOptions’ => array(‘onload’ => ‘function()’),

Hi rudra,

Is that dropdown populated… yesterday i saw one thread regarding that… is that problem solved or still in progress :)

[color="blue"]Hi, [/color]

[color=“blue”]look at the sample code onSelect,onChange will help you :)[/color]

http://www.yiiframework.com/extension/combobox/

Hello Chandran,

Thanks for your support. The dropdownlist works fine but the problem is the data is getting cached.

Hi,

you can try cache setting as false…

Hello Sarthak,

Tried with your option, but it does not work. I tried adding a function this works but I have a problem

Hello Sarthak,




<script>

    var removed;    

function cost_change(price) {

 

    var value = price;

    console.log("value",value);   

    jQuery('#max').prepend(removed);

    var toKeep = jQuery('#max option').filter( function( ) {

        return parseInt(this.value) > parseInt( value);

       

 } );     

   removed =  jQuery('#max option').filter( function( ) {

            return parseInt(this.value) < parseInt( value);

        } );


   console.log("to keep",toKeep);

   jQuery('#max').html(toKeep);

}

</script>



Problem is :

If first dropdownlist takes value 2 then second dropdownlist displays 3,4,5 but next if I select 1 from first dropdownlist the it shows 3,4,5 instead of 2,3,4,5