Well, I tried this before I posted but I must have gotten a caches page or
something but the key was to add <?php echo \$this->Js->writeBuffer(); ?> just
before the block end.
Otherwise the jquery bind events were in the #content section and were
continually being added, so after 3 submissions each element ended up with
the same event bound to it multiple times...
On Wednesday, May 1, 2013 12:10:00 PM UTC-5, Anthony wrote:
>
> Sorry, if this happens to be a repost, groups is acting weird for me today
> with multiple accounts and I don't know if my other post was submitted or
> not..
>
> I have the following layout: (the reason I'm putting the search form into
> its on block is so that the form isn't reloaded when #content is updated
> causing loss of focus and other issues when entering data into the field)
>
> <div class="row-fluid">
> <?php echo $this->Session->flash(); ?>
> <div class="offset10 span2">
> <?php echo $this->fetch('search'); ?>
> </div>
> <div class="row-fluid">
> <div class="span3">
> <?php echo $this->fetch('sidebar'); ?>
> </div>
> <div id="content" class="span9">
> <?php echo $this->fetch('content'); ?>
> </div>
> </div>
> </div>
>
> and the following in my index views:
>
> <?php $this->start('search'); ?>
> <?php
> $data = $this->Js->get('#ItemIndexForm')->serializeForm(array('isForm' =>
> true, 'inline' => true));
> $this->Js->get('#ItemIndexForm
> #ItemName')->event('keyup',$this->Js->request(array('action' => 'index'),
> array('update' => '#content', 'data' => $data, 'async' => true, 'method' =>
> 'POST')));
> $this->Js->get('#ItemIndexForm')->event('submit',
> $this->Js->request(array('action' => 'index'), array('update' =>
> '#content','data' => $data,'async' => true, 'method' => 'POST')));
> ?>
> <?php echo $this->Form->create('Item'); ?>
> <?php echo $this->Form->input('Item.name'); ?>
> <?php echo $this->Form->submit(); ?>
> <?php echo $this->Form->end(); ?>
> <?php $this->end(); ?>
>
> When I submit the form or press a key everything works as expected a
> request is fired off and #content is updated.
>
> However, each request results in an exponential number of requests, based
> on what I know about jquery the problem is that its rebinding the keyup and
> submit bindings when its receiving the new data. I'm guessing that
> having the search form fetched from its own content block is whats causing
> this behavior. Is there a better way to go about this? How can I fix it?
>
--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.