Friday, February 27, 2009

Re: using ajax helper to reload an element

OK, finally getting a chance to look at this again. The biggest
problem I'm having is passing variable information to the element, so
that it can reduce the scope of what's returned and filter based on a
drop down selection.

Here's some code snippets:

http://bin.cakephp.org/view/168041585

Basically, I've gotten it to call the element from within a 'refresh'
view, called by the controller. However, Firebug shows *no* data being
sent in the AJAX POST, so I can't seem to get the data for the form
element that changed. The debug log shows no data for $this->data when
logged from the controller (homes).

The CDATA for the AJAX observer seems to be setup right:
//<![CDATA[
new Form.Element.EventObserver('booksubject', function(element, value)
{new Ajax.Request('/homes/latest_books_refresh', {asynchronous:true,
evalScripts:true, parameters:Form.Element.serialize('booksubject')})})
//]]>

I tried wrapping it in a FORM tag but that didn't help. Any ideas what
might be going on here?

Thanks :)

- Corey Crawford

On Feb 11, 9:25 am, WebbedIT <p...@webbedit.co.uk> wrote:
> As this is an AJAX request you are interfacing with the DOM and as
> such it does not matter whether the element to be updated was built
> with a view or element. As long as you have the link/observer calling
> a new instance of ajax.updater and have set it to update the required elementid then all should be happy. Your refreshSearchElement action
> needs a /home/refresh_search_element.ctp view and if you are using the
> RequestHandler component Cake should do all the rest for you.
>
> Have you got FireBug installed? If so what POST and Response data does
> it show for the ajax request?

On Feb 11, 10:32 am, brian <bally.z...@gmail.com> wrote:
> Sorry, I forgot something, actually
>
> $this->layout = false;
> $this->set('new_param', $new_param);
>
> $this->viewPath = 'elements';
>
> /*
> OR:
> $this->viewPath = 'elements'.DS.'some_other_dir';
> */
>
> $this->render('search_element_1');
>
> This will force Cake to use only the element to render the view.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: