[nycphp-talk] ajax and un-breaking the ol' back button
David Mintz
david at davidmintz.org
Wed Apr 2 13:17:07 EDT 2008
On Wed, Apr 2, 2008 at 12:28 PM, csnyder <chsnyder at gmail.com> wrote:
> On Wed, Apr 2, 2008 at 9:53 AM, David Mintz <david at davidmintz.org> wrote:
>
> > Before I start trying to un-break it please tell me if this logic is
> sound:
> > when they do an ajax request, store the query params in the session.
> > Whenever they GET the page itself, look first for these session vars and
> use
> > them if they exist, else use the defaults.
> >
>
> That's probably the easiest way to do it, if you're already using
> sessions.
>
> You could also use js to write the current params directly to cookie.
This works. It's kind of baroque, if not to say warped, but within a
controller method in a Zend Framework app, we go:
$session = new Zend_Session_Namespace('Schedule');
$params = (object) $this->getRequest()->getParams();
$defaultParams = array(
'language'=>'all',
'date' => date('Y-m-d')
);
foreach ($defaultParams as $name => $default) {
if (!empty($params->$name)) {
${$name} = $session->$name = $params->$name ;
} elseif ($session->$name) {
${$name} = $session->$name;
} else {
${$name} = $default;
}
}
// then $date and $language get passed to data-fetching methods in my
model
--
David Mintz
http://davidmintz.org/
The subtle source is clear and bright
The tributary streams flow through the darkness
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20080402/3edb6fca/attachment.html>
More information about the talk
mailing list