Hi everybody!

I have a problem with posting a form.
I use the tree Ajax component of DhtmlGoodies (http://
www.dhtmlgoodies.com/scripts/drag-drop-folder-tree/drag-drop-folder-tree.html)
and I want to save it's structureString to the database. The problem
is that it uses a javascript code to fill the hidden field in the
form.

================================================================
<!-- edit.thtml -->
================================================================
<div id="menuTree_edit">
<ul id="menuTreeContainer" class="DHTMLSuite_tree">
        <li id="node_10000" noDrag="true"><a href="#">MenuBar</a>
        <ul>
           #### TREE STRUCTURE ####
        </ul>
        </li>
</ul>
</div>

<?= $ajax->form(array('action'=>$html->url('save')));?>
<?= $html->hidden('menu_builder/saveString', array('id' =>
'saveString', 'value' => 'none', 'size' => '40')) ?>
<?= $ajax->submit('save tree',array('url'=>'save',
'update'=>'menuTree_edit', 'frequency'=>'2')); ?>

function saveMyTree_byForm()
{
          document.myForm.elements['saveString'].value =
treeObj.getSaveString();
          document.myForm.submit();
}

================================================================

ok then I have my controllerclass

================================================================
<!-- menu_builder_controller.php -->
================================================================
class MenuBuilderController extends AppController {
        var $name = 'MenuBuilder';
        var $helpers = array('Html', 'Javascript', 'Ajax');
        //var $components = array('RequestHandler');

        var $myMenuItems = array();
        var $TreeData=array();

        function index()
        {
                $this->myMenuItems = $this->MenuBuilder->findAll();

                $this->set('menubuilder', $this->myMenuItems);
        if(isset($this->params['requested'])) {
             return $this->myMenuItems;
        }
        }

        function edit(){
                $this->myMenuItems = $this->MenuBuilder->findAll();
                $this->set('menubuilder', $this->myMenuItems);
        }

        function save(){
                $success = true;
                $succesMessage = 'Menu update successfully';
                if (empty($this->data)){
                                $success = false;
                                $errorMessage = "Error in menu updating - no 
data";
                }else{
                            ### some building code ##
                           $this->MenuBuilder-
>save(array('MenuBuilder' => $this->params['data']['item']
['MenuBuilder']));

                }
                $this->render('save', 'ajax');
        }

================================================================

Can somebody tell me how I post my form with the saveString with Ajax
and refresh the result in the edit.thtml menuTree_edit-div. So if I
click save the data is saved and my tree-view updates in the right
region of the screen.

Thanks in advance!
Greetings to you all!


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to