File: /pages/tutorials/object/object-06.php
<?php class Object06 extends Page { public function InitializeComponent() { parent::$PAGE_TITLE = "Tutorial : sortables Objects with event"; // Create drag picture $pic_drag = new Picture("wsp/img/drag_arrow_16x16.png", 16, 16, 0, Picture::ALIGN_ABSMIDDLE); $pic_drag->setStyle("cursor:pointer;"); // *** Sortable area 1 *** $sortable_area_1 = new WSPObject(); $sortable_area_1->setId("sortable_area_1"); // Create sort event $sort_event1 = new SortableEvent($this); $sort_event1->onSort("onSort")->setAjaxEvent(); $sortable_area_1->setSortable(true, $sort_event1); // Create objects to be sort $square1 = new WSPObject($pic_drag, "My Object 1"); $square1->setId("my_object_1_tuto_6")->forceDivTag(); $square2 = new WSPObject($pic_drag, "My Object 2"); $square2->setId("my_object_2_tuto_6")->forceDivTag(); $square3 = new WSPObject($pic_drag, "My Object 3"); $square3->setId("my_object_3_tuto_6")->forceDivTag(); $sortable_area_1->add($square1, $square2, $square3); // *** Sortable area 2 *** $sortable_area_2 = new WSPObject(); $sortable_area_2->setId("sortable_area_2"); // Create sort event $sort_event2 = new SortableEvent($this); $sort_event2->onSort("onSort")->setAjaxEvent(); $sortable_area_2->setSortable(true, $sort_event2); // Create objects to be sort $square4 = new WSPObject($pic_drag, "My Object 4"); $square4->setId("my_object_4_tuto_6")->forceDivTag(); $square5 = new WSPObject($pic_drag, "My Object 5"); $square5->setId("my_object_5_tuto_6")->forceDivTag(); $square6 = new WSPObject($pic_drag, "My Object 6"); $square6->setId("my_object_6_tuto_6")->forceDivTag(); $sortable_area_2->add($square4, $square5, $square6); // Create render $this->render = new Table(5); $this->render->addRowColumns($sortable_area_1, $sortable_area_2); } public function onSort($sender, $moved_object, $from_object, $to_object, $position, $old_position) { alert("Move object ".$moved_object->getId(). " from ".$from_object->getId(). " to ".$to_object->getId(). " on the position ".$position. " (old position: ".$old_position.")"); } } ?>
Go back to tutorial of the componant Object
|