Access JQuery Objects/Widgets

Hi everyone,

I use the Jcrop extension with the following configuration:


        $this->widget('ext.jcrop.EJcrop', array(

            // Image URL

            'url'         => '', // this is left empty, because I want to set it dynamically

            // options for the IMG element

            'htmlOptions' => array('id' => 'imageId'),


            // Jcrop options (see Jcrop documentation)

            'options'     => array(

                //'minSize'     => array(620, 130),

                'setSelect' =>   array(0, 0, 620, 130 ),

                'allowResize' => false,




which gives me the follwing HTML output:


jQuery(function($) {

jQuery('#imageId').Jcrop({'setSelect':[0,0,620,130],'allowResize':false,'onChange':function(c) {ejcrop_getCoords(c,'imageId'); ejcrop_showThumb(c,'imageId');},'ajaxUrl':null,'ajaxParams':[]});



How can I access this object once the widget is rendered? I want to call setImage() which is a method of the Jcrop object, but how do I access the Jcrop object?

moved to proper forum ( extensions )

I think it was in the correct forum since this isn’t an extension related problem. Jcrop is the one I’m currently stuck on, but I guess this affects all the widgets that wrap a jQuery object. In the jQuery examples they always keep track of objects like that (again Jcrop as an example):

var jcrop_api;


  jcrop_api = this;


But since I can’t modify this code directly I wonder how to do this in Yii.

that depends much on how the jquery plugin is made.

To solve your problem, I would change the extension’s code and add the code above to the JS generated code.