Sunday, February 28, 2010

Re: How to set "paginate -> limit" on the fly in my views?

Well as paginate expects the variables page, sort, direction and limit
from a GET request you would have to submit the form and redirect, or
use javascript to grab the textfield value form the right url and
submit a new GET request.

Have a look at the following page:
http://new.localcause.org.uk/articles

I include a form at the top of my index including two select lists
with onchange events which call the below javascript function

<script>
// <![CDATA[
function indexOptions() {
var sort = $('IndexOptionSort').getValue();
var direction = $('IndexOptionDirection').getValue();
window.location = "/<?php echo $this->params['controller']; ?>/<?
php echo $this->params['action']; ?>/sort:" + sort + "/direction:" +
direction;
}
// ]]>
</script>

P.S. I am a self-confessed novice with javascript so know this could
probably be done better

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

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: