You know what? Ignore that.. I'm severely under slept and over, erm, drank.

You'll want to call this:
$this->_helper->layout->disableLayout();

Jason Webster wrote:
If you call:
    $this->_helper->viewRenderer->setNoRender(true);
From somewhere in your controller it will not render anything unless explicitly asked to; which in your case, you do with your call to the render() method on the action controller. But, setting this flag will not render the layout.


MarkDNA wrote:
Hi there to all first post, so go easy on the newbie :-)

I've done PHP for several years, and a bit of AJAX, though a while ago
(cpaint anyone?). New to ZF and Dojo. Trying to get a simple xhrPost to work
right and having issues - not sure if it's ZF or Dojo.
When my ajax cal lis returned - it adds in the entire layout to the response div instead of just the partial. Is there a way to just render the partial
and have that inserted? I think this is something I need to do in the
controller so that the entire layout is not rendered - just the view.
Perhaps something with named segments?

MVC Application

Controller:
    public function editajaxAction(){
        switch($this->_getParam('formType')){
            case "addPlantUse":
                //Insert use data for the plant into the rel table
                Zend_Loader::loadClass('PlantsPlantUses');
                $useObject = new PlantsPlantUses();
                $data = array(
                    "plantID" => $this->_getParam('plantID'),
                    "useAbbreviation" => $this->_getParam('plantUse'));
                $useObject->insert($data);
//Get new list of uses for this plant
                $plant = new Plants();
                $plantRowSet = $plant->find($this->_getParam('plantID'));
                $plantRow = $plantRowSet->current();
                $plantUses = $plantRow->findManyToManyRowset('PlantUses',
'PlantsPlantUses');
//Add data to the view
                                $this->view->useList =
$plantUses->toArray();
                $this->render('editPlantUsePartial'); break;
        }
    }

layout.phtml
[SNIP]
<? if ($this->dojo()->isEnabled()){
    $this->dojo()->setLocalPath(BASEURL.'js/dojo/dojo.js')
                 ->addStyleSheetModule('dijit.themes.tundra');
    echo $this->dojo();
   }
?>
</head>
<body>
<?= $this->partial('header.phtml') ?>
<div id="resultcell">
<?= $this->layout()->content ?>
</div>
</div>
<?= $this->partial('footer.phtml') ?>
</body>
</html>

edit.phtml
<? $this->dojo()->javascriptCaptureStart() ?>
var ajaxAdd = function(divID, formName) {
    var kw = {
        url: "<?=BASEURL."plants/index/ediajax"?>",
        handleAs:"text",
        load: function(response){
                dojo.byId(divID).innerHTML = response;
        },
        error: function(data){
                alert("An error occurred: " + data);
        },
        timeout: 2000,
        form: formName
    };
    dojo.xhrPost(kw);  //Servlet get argement with doPost
}
    <? $this->dojo()->javascriptCaptureEnd() ?> ....
(I'm being generic so I can use this for multiple forms on the page)
....
<div id="plantUses"> //The partial is displayed properly on load, but
whole layout displayed after AJAX call
<?=$this->partial('index/edit-plant-use-partial.phtml', array("useList"
=>$this->info["uses"]))?>
      </div>

edit-plant-use-partial.phtml
<ul style="margin-top: 0px">
<? foreach ($this->useList as $use) {
    echo "<li>
\"".BASEURL."plants/use/detail/useAbbreviation/".$use["useAbbreviation"]."\"
".$use["useAbbreviation"]." - ".$use["useName"]." </li>";
}
?></ul>

-Mark G.


Reply via email to