Yii Framework Forum: CJuiSortable (basic question) - Yii Framework Forum

Jump to content

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

CJuiSortable (basic question) CJuiSortable Rate Topic: -----

#1 User is offline   chux 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 83
  • Joined: 16-September 10

Posted 23 October 2010 - 06:54 AM

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.yiiframew....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
Give a read to my blog.
0

#2 User is offline   chux 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 83
  • Joined: 16-September 10

Posted 23 October 2010 - 06:52 PM

i know this is a very basic question, but i cant find how to do it... please, give me a hand
Give a read to my blog.
0

#3 User is offline   tri 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,651
  • Joined: 20-November 08
  • Location:Stockholm, Sweden

Posted 23 October 2010 - 09:53 PM

View Postchux, on 23 October 2010 - 06:52 PM, said:

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?
Don't forget to read The Definitive Guide to Yii (en) (sv) | The class reference has the details
0

#4 User is offline   chux 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 83
  • Joined: 16-September 10

Posted 24 October 2010 - 04:48 AM

my question is how can i change the default code that autocomplete widget generates
Give a read to my blog.
0

#5 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,339
  • Joined: 12-October 09
  • Location:Croatia

Posted 24 October 2010 - 06:21 AM

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...
Find more about me.... btw. Do you know your WAN IP?
0

#6 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,448
  • Joined: 04-October 10

Posted 24 October 2010 - 06:42 AM

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!)
¿How long would it take for you to understand that you own nothing in this world?

www.ramirezcobos.com
www.2amigos.us
www.github.com/tonydspaniard
www.github.com/2amigos


Posted Image
0

#7 User is offline   chux 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 83
  • Joined: 16-September 10

Posted 24 October 2010 - 09:03 AM

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
Give a read to my blog.
0

#8 User is offline   chux 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 83
  • Joined: 16-September 10

Posted 24 October 2010 - 09:12 AM

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
Give a read to my blog.
0

#9 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,448
  • Joined: 04-October 10

Posted 25 October 2010 - 12:19 PM

View Postchux, on 24 October 2010 - 09:12 AM, said:

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



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
¿How long would it take for you to understand that you own nothing in this world?

www.ramirezcobos.com
www.2amigos.us
www.github.com/tonydspaniard
www.github.com/2amigos


Posted Image
1

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