thanks xavier. you got my point exactly. i'll be looking into your code and see if it can work for me. i'll also post an update for on my progress. thanks again! :working:
Xavier Vidal wrote: > > Last year we need something similar as Xajax, and i've developed a simple > class to achieve this functionality, but only the server part. The client > part is hardcoded with javascript helpers. > > You can find a snippet here: http://www.pasteyourcode.com/34 > > A example could be useful: > > Class IndexController extends Zend_controller_Action > { > public function ajaxAction() > { > // disable view renderer > > $ajax = Xvp_Ajax::getInstance(); > $ajax->appendContent("$('#box').html('this is a test')"); > $ajax->appendContent("alert('bingo')"); > $ajax->render(); > } > } > > This example uses Jquery. In the template, you can put something like: > > <script type="text/javascript"> > function refresh() { > $.ajax({ > type: "POST", > url: "/default/index/ajax", > dataType: "script", > }); > }; > </script> > > <div id="box" style="border:1px solid #ccc;width:100px;height:100px"> > </div> > > <input type="button" onclick="refresh()" id="refresh" value="Refresh" > name="refresh"> > > Hope it helps ! > > -----Mensaje original----- > De: chronoel22 [mailto:chronoel...@yahoo.com] > Enviado el: jueves, 30 de abril de 2009 17:36 > Para: fw-general@lists.zend.com > Asunto: [fw-general] doing xajax like operation in zend framework > > > hi i was wondering if the zend framework provides a built-in way of > manipulating html from the controller/action using ajax and javascript. > i'm > referring to how xajax and sajax does this. you see they implement > something > like the following on the php script: > > $x = new xajax(); > $x->setStyle('aClass', 'display:none'); > > to manipulate the html and set the style of elements with class aClass to > 'display:none' > > <div class="aClass">some content</div> > > now, moving on the mvc approach. i was thinking of a similar way to handle > an ajax request to '/ajax/save/'. the said action will save some data > passed > by the ajax request and return a notification on the success of the > operation. it will do so by creating a new div on the html an displaying > the > message in it. following is an imaginary code of the said idea. > > class AjaxControler extends Zend_Controller_Action { > public function saveAction() { > $data = getParam('data'); > // save $data probably to database > > $x = new xajax(); > $x->addDiv('Data successfully saved', 'position:centered'); > } > } > > now, as you see. i'm not defining any view scripts. and i hope your > getting > my point. any nice ideas about this. am i doing this right? > -- > View this message in context: > http://www.nabble.com/doing-xajax-like-operation-in-zend-framework-tp2331879 > 2p23318792.html > Sent from the Zend Framework mailing list archive at Nabble.com. > > > > -- View this message in context: http://www.nabble.com/doing-xajax-like-operation-in-zend-framework-tp23318792p23328888.html Sent from the Zend Framework mailing list archive at Nabble.com.