CJuiSortable (basic question)

Hi everybody,

Im using for the first time the zii.widget.jui, my question is regarding to CJuiSortable

This code is working:




$this->widget('zii.widget.jui.CJuiSortable', array(

		'items'		=> $elementos,

		'id'		=> 'elementos_lista',

		'options'	=> array(

				'delay'		=> '300'

			)

	));



but i need another markup different that the generated one.

I have look the documentation here, and y see it has a itemTemplate property

http://www.yiiframework.com/doc/api/1.1/CJuiSortable

The question is… how do i provide a different template?

This is not working




$this->widget('zii.widgets.jui.CJuiAutoComplete', array(

		'name'		=> 'elementos_select',

		'itemTemplate' => '<li id="elemento_{id}">{content}</li>',

		'value'		=> '',

		'source'	=> $this->createUrl('elemento/list'),

		'options'	=> array(

				'showAnim'		=> 'fold',

				//los eventos de este, por claridad, los voy a poner directamente en el js (coaster_modificar.js) tal y como aparece en la documentación de jqueryui

			)

		)

	);



Thanks

i know this is a very basic question, but i cant find how to do it… please, give me a hand

CJuiAutoComplete? Did you change the wtong widget?

my question is how can i change the default code that autocomplete widget generates

Your question is a bit unclear…

becasue in your question you write about the CJuiSortable->itemTemplate

but in the "not working example" you use CJuiAutoComplete that does not have the itemTemplate…

I agree with mdomba, in your first example you put the items directly, on the second you use the ‘source’ property. I recommend you to do the first example like the following to test it




$this->widget('zii.widget.jui.CJuiSortable', array(

                'items'         => $elementos, // <--- elements like this first! 

                'id'            => 'elementos_lista',

                'itemTemplate' => '<li id="elemento_{id}">{content}</li>',

                'options'       => array(

                                'delay'         => '300'

                        )

        ));




And if it works, then try with the source property!

As you can see on this line of code here, to change the itemTemplate isn’t rocket science (review it carefully, I am sure you will do it!)

my mistake, sorry. I didn’t understand your answers cause my poor english.




$this->widget('zii.widget.jui.CJuiSortable', array(

		'items'		=> $elementos,

		'id'		=> 'elementos_lista',

		'options'	=> array(

				'delay'		=> '300'

			)

	));



im using sortable in that way, but i dont know how to change the code that if generates. I supose i have to use itemTemplate, but i dont know how to use it in the widget (first time use).

Thanls for the replies

Ok, this was very stupid, i was putting the code in the wrong widget, as you suggested.

I think im going to have some english leassons before continue my web application…


	

$this->widget('zii.widget.jui.CJuiSortable', array(

		'items'			=> $elementos,

		'id'			=> 'elementos_lista',

		'itemTemplate' => '<li id="{id}" class="{id}">{content}</li>',

		'options'	=> array(

				'delay'		=> '300'

			)

	));



Thank you very much, guys

Sometimes we just need to review carefully our code, the answer is right in front of our eyes and we don’t see it.

Congrats