Re: How to use $ajax->sortable and update in a db?

2006-11-10 Thread Eric

Yes! It works also.










sortable('sections', array('url'=>'Order'));
?>

More loving cake!
Thanks buddy jmn2k1 !


"jmn2k1 写道:
"
> ups...
>
> Where I wrote:
> "the sortable don't work pretty well under IE.."
> I should write:
> "the sortable don't work pretty well WITH TABLES AND TRs under IE..."


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How to use $ajax->sortable and update in a db?

2006-11-10 Thread jmn2k1

ups...

Where I wrote:
"the sortable don't work pretty well under IE.."
I should write:
"the sortable don't work pretty well WITH TABLES AND TRs under IE..."


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How to use $ajax->sortable and update in a db?

2006-11-10 Thread jmn2k1

Actually you don't have to specify the onUpdate argument... if you put
just "url" => "order" (assuming the view is part of sections
controller) it has to work.

look at my complete view code:
[code]







sortable('sortableitems', array('tag'=>'tr',
'url'=>'Order'));
?>
[/code]

The only thing that change is the tag argument, because "li" is the
default.
(As a side note: the sortable don't work pretty well under IE..)


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How to use $ajax->sortable and update in a db?

2006-11-10 Thread Eric

Finally!Finally

sortable('sections',array('onUpdate' => " function(t){new
Ajax.Request( 'http://localhost/cake/sections/order',
{method:'post',
postBody:Sortable.serialize('sections'), asynchronous:true})}"))?>

MUST change the new
Ajax.Request('http://localhost/cake/sections/order',.)
like this...

The Absolute Address


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How to use $ajax->sortable and update in a db?

2006-11-10 Thread Eric

When I try to type like http://localhost/cake/sections/order

Notice: Undefined index: form in D:\Program
Files\xampp\htdocs\cake\app\controllers\sections_controller.php on line
12

Still donesn't work...
Always the same order...

Why...

I do the exactly the same.
Form the database to view file.


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How to use $ajax->sortable and update in a db?

2006-11-10 Thread purepear

Petr, i can't understand your problem... but i missed to skip the 'view
render' so ... the function goes like this:

function order(){
  $ids= $this->params['form']['items'];
  $i = 1;
  foreach($ids as $id){
$this->Item->id = $id;
$this->Item->saveField('position', $i++);
  }
$this->autoRender = false;
}

this will save you some error messages in the responseText...
If you explain your problem again.. i might be able to help

Your question : check out the scriptaculous sortable options and
examples.
Sore but i haven't got the time to go into details now.. got to work.
:)


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How to use $ajax->sortable and update in a db?

2006-11-09 Thread Petr Vytlačil

One question, how I can do sorting in two dimensions. Now its go only
in vertical dimension.


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How to use $ajax->sortable and update in a db?

2006-11-09 Thread Petr Vytlačil

I tested your code but it isnt go. Ther is my code:
--

SQL Table:
===
name_tabel: section
id: int
name: varchar
position: int

Section Model:
===


Section Controller:
=
set('sections', $this->Section->findAll());
}

function order(){
$ids= $this->params['form']['sections'];
$i = 1;
foreach($ids as $id){
$this->Section->id = $id;
$this->Section->saveField('position', $i++);
}
}
}
?>
Section Views:
=
INDEX VIEW


  


  

 sortable('sections',array('onUpdate' => " function(t){new
Ajax.Request( '/sections/order', {method:'post',
postBody:Sortable.serialize('sections'), asynchronous:true})}"))?>

I test it with FireBag in Firefox v2, when I resort some section. Its
return dont finde controller becouse it finding method order on link
http://localhost/sections/order. So when I change: sortable('sections',array('onUpdate' => " function(t){new
Ajax.Request( '/sections/order', {method:'post',
postBody:Sortable.serialize('sections'), asynchronous:true})}"))?>
on
sortable('sections',array('onUpdate' => " function(t){new
Ajax.Request( 'http://localhost/zakazky/eshop/sections/order',
{method:'post',
postBody:Sortable.serialize('sections'), asynchronous:true})}"))?>

its return isnt view for method order, but position section is save.

THX


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How to use $ajax->sortable and update in a db?

2006-11-09 Thread purepear

So... in short :
___  VIEW ( index.thtml )  __


  

  


 sortable('items',array('onUpdate' => " function(t){new
Ajax.Request( '/items/order', {method:'post',
postBody:Sortable.serialize('items'), asynchronous:true})}"))?>

 CONTROLLER ( items_controller.php ) 

function order(){
  $ids= $this->params['form']['items'];
  $i = 1;
  foreach($ids as $id){
$this->Item->id = $id;
$this->Item->saveField('position', $i++);

}

___ DATABASE __
table 'items' which has field called 'position'



I'm not using Items in my source, so there might be some mistakes, but
thats the main idea :)


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How to use $ajax->sortable and update in a db?

2006-11-09 Thread purepear

Damn...i did it... i was playing with
$ajax->sortable('items',array('url' => '/items/order')) ... for example
I use firebug to catch the request -  the parameters are wrong... it
seems that they are not in UTF-8.

The ajax helper generates js that prints  
parameters:sortable.serialize('items') 
Instead use sth. like :
sortable('items',array('onUpdate' => " function(t){new
Ajax.Request( '/items/order', {method:'post',
postBody:Sortable.serialize('items'), asynchronous:true})}"))?>

If you wish you can fix the ajaxhelper instead of writing that js every
time.

And the function that catches that request :

function order(){
  $ids= $this->params['form']['items'];
  $i = 1;
  foreach($ids as $id){
$this->Item->id = $id;
$this->Item->saveField('position', $i++);
}

note: Your 'items' db table must have 'position' field
Hope i helped :)


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How to use $ajax->sortable and update in a db?

2006-11-09 Thread f.

> BUT i am confused where should I put the submit_sort?
> Creat a new js file? or PUT them in the index.thtml?
> I was created a new function in my controlloer called submit_sort( ),
> and paste your code. It was wrongl

I put in my view (note the wrapping 

Re: How to use $ajax->sortable and update in a db?

2006-11-09 Thread Eric

Thanks for your patient!
BUT i am confused where should I put the submit_sort?
Creat a new js file? or PUT them in the index.thtml?
I was created a new function in my controlloer called submit_sort( ),
and paste your code. It was wrongl

THanks.
Asking so silly question.


f. wrote:
> Hi,
>
> > Should I creat a field called order in my, such as topics table?
> >
>
> Yes, you should.
> What worked for me:
>
>
> In my view, I have a div with the sortable items:
> 
> 
>  class="sortablediv">
> whatever...
> 
> 
> 
>
> I create the sortable js-code with
>
> sortable('sortlist', array(
> 'tag'   => 'div',
> 'onUpdate'  =>
> 'submit_sort'
> )); ?>
> You need to define the function to submit the data:
> 
> function submit_sort() {
> var u = new Ajax.Updater('col4', /* i update a div with the
> results,,, */
> ' $html->url('/admin/articles/sort/'.$catid).'?' ?>' +
> Sortable.serialize('sortlist'),
> {
>
> onLoading:function(request){$('indicator').show()},
>
> onLoaded:function(request){$('indicator').hide()},
> asynchronous:true,
> evalScripts:true,
> requestHeaders:['X-Update', 'col4']
> }, false);
> }
> 
> the important part is to append the serialized list to the URL.
> Later in your controller you can access the data with
> $this->params['url']['sortlist']:
> if (!empty($this->params['url']['sortlist'])) {
> for ( $i=0; $i < count($this->params['url']['sortlist']);
> $i++ )
> {
> $this->Article->id =
> $this->params['url']['sortlist'][$i];
> $this->Article->saveField('sort', $i);
> }
> }
> 
> hope this helped,
> 
> f.


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How to use $ajax->sortable and update in a db?

2006-11-09 Thread f.

Hi,

> Should I creat a field called order in my, such as topics table?
>

Yes, you should.
What worked for me:


In my view, I have a div with the sortable items:



whatever...




I create the sortable js-code with

sortable('sortlist', array(
'tag'   => 'div',
'onUpdate'  =>
'submit_sort'
)); ?>
You need to define the function to submit the data:

function submit_sort() {
var u = new Ajax.Updater('col4', /* i update a div with the
results,,, */
'url('/admin/articles/sort/'.$catid).'?' ?>' +
Sortable.serialize('sortlist'),
{

onLoading:function(request){$('indicator').show()},

onLoaded:function(request){$('indicator').hide()},
asynchronous:true,
evalScripts:true,
requestHeaders:['X-Update', 'col4']
}, false);
}

the important part is to append the serialized list to the URL.
Later in your controller you can access the data with
$this->params['url']['sortlist']:
if (!empty($this->params['url']['sortlist'])) {
for ( $i=0; $i < count($this->params['url']['sortlist']);
$i++ )
{
$this->Article->id =
$this->params['url']['sortlist'][$i];
$this->Article->saveField('sort', $i);
}
}

hope this helped,

f.


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How to use $ajax->sortable and update in a db?

2006-11-08 Thread Eric

>Where "order" is an action in your controller where you can do
> something like:
>
> if (isset($_POST['items']))
> {
> $sortableitems = $_POST['items'];
>
> $i = 0;
> foreach ($sortableitems as $item)
> {
> $this->UsefulLink->id = $item;
> $this->UsefulLink->saveField('order', $i);
> $i++;
> }
> }

Should I put a  to include the view files,like

> 
> Item
> Other Item
> 


AND,   for  ''  $this->UsefulLink->saveField('order', $i); ''
Should I creat a field called order in my, such as topics table?


FOR MY OWN ONE:
views/topics/index.thtml







sortable ("items",array('url'=>'order')) ?>

controller/topics_controller.php
   if (isset($_POST['items']))
{
$sortableitems = $_POST['items'];

$i = 0;
foreach ($sortableitems as $item)
{
$this->Topic->id = $item;
$this->Topic->saveField('order', $i);
$i++;
}
}

AND, I creat a field called ORDER in my topics table.

IT doesn't work.
Can U help me to figure it out where should I edit for make it works?


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How to use $ajax->sortable and update in a db?

2006-11-08 Thread Eric

Quite Strange...!!

It doesn't work


This is the first list
 





sortable ("firstlist",array()) ?

Last day was OK !!!
BUT now
Error: Sortable is not defined
Source File: http://localhost/ck/topics
Line: 131

Why It Happen ???
I do nothing about this page
Someone occur it before?


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How to use $ajax->sortable and update in a db?

2006-11-08 Thread jmn2k1

Here you have more info about the parameters and other things..
http://wiki.script.aculo.us/scriptaculous/show/Sortable.create

Basically you have to do something like:


Item
Other Item


Where "1", "4" are (in this example) the ids of the items, and then add
the sortable javascript with the Ajax helper:
sortable('items', array('url'=>'order'));?>

Where "order" is an action in your controller where you can do
something like:

if (isset($_POST['items']))
{
$sortableitems = $_POST['items'];

$i = 0;
foreach ($sortableitems as $item)
{
$this->UsefulLink->id = $item;
$this->UsefulLink->saveField('order', $i);
$i++;
}
}


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---