On Feb 14, 5:12 am, Jens Dittrich <jdittr...@gmail.com> wrote:
> Hello,
>
> I have a problem understanding/using the $js->request() function. I
> want to use it to get the value of an input field and send the value
> on an event. But how do I get the value of the input field into the
> requests parameter? My setup is like this:
> $this->Js->get('input')->event('click',$this->Js->request(
>   array('action' => 'search'), // <-- shouldn't the parameter go in
> here? How to do that with Js?
>   array('update' => 'target'
> ));
>
> Whe using:
> $this->Js->get('input')->event('click', $this->Js->request(
>   array('action' => 'search'),
>   array('update' => 'target',
>          'dataExpression' => true,
>          'data' => '$(input).val()'
> ));
> I get a request like ..url/controller/action?value which I do not know
> how to access with cakePHP.
>

Well first off, you're doing a GET request, and it sounds like you
want to do a POST request.  Also 'data' in most javascript libraries
takes an object/dictionary of data, you have a single string.  This
too may cause issues.

$this->Js->get('input')->event('click', $this->Js->request(
    array('action' => 'search'),
    array('update' => 'target',
          'dataExpression' => true,
          'data' => '{value:$(input).val()}'
    )));

One more thing, your selector is extremely greedy, and will bind
events to every input on the page, this is probably not what you
wanted.  Or perhaps it is, I dunno.

-Mark

> What am I doing wrong?
>
> Thank you for your help & time

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to