开发者

cakephp updating elements

I have an index view which has some elements on it .

index controller code;

    $userID = $this->Authsome->get('id');       
$qnotes = $this->Qnote->getnotes($userID);  
$this->set('qnotes', $qnotes)
$this->render();

elements have been added to the page using

index view code

<?php echo $this->element('lsidebar'); ?> 

now the Issue is I also Have an add controller.

add controller code

    function add() {  
    if(!empty($this->data)) {      
        unset($this->Qnote->Step->validate['qnote_id']);
        $this->Qnote->saveAll($this->data); 
        $this->Session->setFlash('New Note Template has been added.','flash_normal');


    }       
}

now what I am trying to achieve is once I add a Qnote i want the element('lsidebar') updated for the new Qnote.

I am Using the Ajax helper. found at http://www.cakephp.bee.pl/

also Here the add qnote View Code :

<?php echo $ajax->submit(
'Submit', array(
    'url' => array(
        'controller'=>'qnotes',
        'action'=>'add')

)); 

I know its sound like a noob question . can Somebody point me in the right direction atleast. I have tried everything i could think off. I bet the solution something easy which i didnt think off

h开发者_C百科elp :)


If you want to dynamically update a sidebar with information that is submitted via ajax, there should be a "success" option in your ajax post that would allow you to fire a specific javascript action when the post is finished (or succeeds). You should write a small javascript ajax function to reload the contents of your sidebar when the post succeeds. See this other stackoverflow answer: CakePHP ajax form submit before and complete will not work for displaying animated gif

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜