Yii Framework Forum: Yii - How Can I Call A Script From Ejuicombobox Widget - Yii Framework Forum

Jump to content

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

Yii - How Can I Call A Script From Ejuicombobox Widget

#1 User is offline   Rudra 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 111
  • Joined: 12-July 13

Posted 13 November 2013 - 01:02 AM

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'),
        ));
        ?>


0

#2 User is offline   sarthak 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 11
  • Joined: 19-December 12
  • Location:Ahmedabad, Gujarat, India

Posted 13 November 2013 - 01:29 AM

you may use onload in htmlOptions.


like,
'htmlOptions' => array('onload' => 'function()'),
0

#3 User is offline   chandran 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 488
  • Joined: 08-October 12
  • Location:Austria

Posted 13 November 2013 - 04:12 AM

Hi rudra,

Is that dropdown populated.. yesterday i saw one thread regarding that.. is that problem solved or still in progress :)
Thanks
chandran nepolean

My own extension:
http://www.yiiframew...sion/ejqueryte/

My wiki
http://www.yiiframew...checkboxcolumn/

If it work dont hesitate to click +1 button
0

#4 User is offline   chandran 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 488
  • Joined: 08-October 12
  • Location:Austria

Posted 13 November 2013 - 04:18 AM

Hi,

look at the sample code onSelect,onChange will help you :)


http://www.yiiframew...nsion/combobox/
Thanks
chandran nepolean

My own extension:
http://www.yiiframew...sion/ejqueryte/

My wiki
http://www.yiiframew...checkboxcolumn/

If it work dont hesitate to click +1 button
0

#5 User is offline   Rudra 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 111
  • Joined: 12-July 13

Posted 13 November 2013 - 04:49 AM

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

#6 User is offline   chandran 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 488
  • Joined: 08-October 12
  • Location:Austria

Posted 13 November 2013 - 07:20 AM

View PostRudra, on 13 November 2013 - 04:49 AM, said:

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..


Thanks
chandran nepolean

My own extension:
http://www.yiiframew...sion/ejqueryte/

My wiki
http://www.yiiframew...checkboxcolumn/

If it work dont hesitate to click +1 button
0

#7 User is offline   Rudra 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 111
  • Joined: 12-July 13

Posted 14 November 2013 - 12:17 AM

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

View Postsarthak, on 13 November 2013 - 01:29 AM, said:

you may use onload in htmlOptions.


like,
'htmlOptions' => array('onload' => 'function()'),

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
0

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