LEGAL
#===========================================================================
Copyright (C) 2008 by Nik Ogura. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Bug reports and comments to nik.ogura@gmail.com.
#=========================================================================== =head1 NAME
CGI::Lazy::Javascript
SYNOPSIS
use CGI::Lazy;
my $q = CGI::Lazy->new();
my $widget1 = $q->ajax->activeDataSet({...});
my $widget2 = $q->ajax->activeDataSet({...});
print $q->header,
$q->javascript->modules($widget1, $widget2);
DESCRIPTION
CGI::Lazy::Javascript is predominately a javascript container. It holds the js modules necessary for widgets to function, and outputs them for printing to the browser.
It's only real method is modules() which outputs the javascript necessary to run whatever modules get passed as arguments, or in the event that there are none, it will just output the basics, such as a JSON parser, and Ajax routines
METHODS
q ( )
Returns CGI::Lazy object.
modules ( components )
Returns javascript for parsing JSON and making ajax calls, as well as the clientside goodness for the ajax widgets. This method needs to be printed on any page that is going to use JSON or the Ajax objects.
It's included as a separate method as it should be sent only once per page, and would be included in the header except this would be an irritation for cases where CGI::Lazy is not using Ajax objects. If called without components, it will send out only the defaults listed below.
components
List of widgets whose javascript needs to be loaded. JSON parser, ajaxSend, and sjaxSend are exported by default, the rest is on a per widget basis.
The modules method is smart enough to only output the necessary code for a given type of module once. Multiple widgets of the same type will not result in the same code being printed over and over.
For composite widgets, it loads each constituent widget in turn.
new ( q )
constructor.
q
CGI::Lazy object