[Catalyst] Losing subrequest output
Bill Moseley
moseley at hank.org
Tue Dec 13 17:05:14 CET 2005
On Tue, Dec 13, 2005 at 12:48:09PM +0000, Nigel Metheringham wrote:
> Inspired by http://catalyst.perl.org/calendar/2005/12 and yesterdays
> experiments with AJAX I decided to change my code to use subrequests
> rather than outputting the same item twice in different contexts.
[...]
> <label>
> <span class="field">Group</span>
> <div id="select_group0">
> [% Catalyst.subreq('/ajax/select_groups', {}, {
> bs_sp => item.bs_sp.id,
> default => 1}); %]
> </div>
> </label>
Another approach might be to break your page down into smaller
templates or template blocks. Then when processing a full page (like
in the example above) you "PROCESS select_group0" inline, and for Ajax
requests then the controller just specifies the template is
select_group0. That avoids the need for a subrequest and avoids
having the view call the controller.
I have a few Ajax features that duplicate features that are available
as normal page requests. In these cases I use the same controller for
both, but after setting up, for example, the database query I then do:
return $c->forward('/ajax_request') if $c->is_ajax;
which builds and returns a standard list.
As another example, I also have my main wrapper TT template decided
how to format pages (include page headers/footers layout) based on
if a request is an ajax request or not.
--
Bill Moseley
moseley at hank.org
More information about the Catalyst
mailing list