| HTML-PopupTreeSelect-Dynamic documentation | view source | Contained in the HTML-PopupTreeSelect-Dynamic distribution. |
HTML::PopupTreeSelect::Dynamic - dynamic version of HTML::PopupTreeSelect
This module is used just like HTML::PopupTreeSelect, with the addition
of 3 new parameters - dynamic_url, dynamic_params and include_prototype. Here's
a full example:
use HTML::PopupTreeSelect::Dynamic;
# setup your tree as a hash structure. This one sets up a tree like:
#
# - Root
# - Top Category 1
# - Sub Category 1
# - Sub Category 2
# - Top Category 2
my $data = { label => "Root",
value => 0,
children => [
{ label => "Top Category 1",
value => 1,
children => [
{ label => "Sub Category 1",
value => 2
},
{ label => "Sub Category 2",
value => 3
},
],
},
{ label => "Top Category 2",
value => 4
},
]
};
# create your HTML tree select widget. This one will call a
# javascript function 'select_category(value)' when the user selects
# a category.
my $select = HTML::PopupTreeSelect::Dynamic->new(
name => 'category',
data => $data,
title => 'Select a Category',
button_label => 'Choose',
onselect => 'select_category',
dynamic_params => 'rm=get_node');
# include it in your HTML page, for example using HTML::Template:
$template->param(category_select => $select->output);
A complete, and terribly coded, example of how to use this modules is
included in the module distribution. Look for the file called
hpts_demo.cgi.
This module provides a dynamic version of HTML::PopupTreeSelect. By dynamic I mean that the tree is sent to the client in chunks as the user clicks around the tree. In HTML::PopupTreeSelect the entire tree is sent to the client when the page is loaded, introducing a long delay for large trees. With HTML::PopupTreeSelect::Dynamic trees of virtually any size can be navigated without noticable delays.
Be aware of the following issues, some or all of which may be fixed in a future version:
data parameter
to new(). In general this is considerably less problematic than
sending the entire tree to the client, but it would be nice to remove
this potential bottleneck as well. http://prototype.conio.net/
$select = HTML::PopupTreeSelect::Dynamic->new(
dynamic_url => 'http://example.com/tree_select.cgi',
...);
dynamic_url. These should be in URL format. For example, to
set "rm" to "get_node":
$select = HTML::PopupTreeSelect::Dynamic->new(
dynamic_params => 'rm=get_node',
...);
Prototype.js that comes
from HTML::Prototype. By default it is true.
false when you are already using
prototype.js in your templates via a <script> tag.
dynamic_url and dynamic_params. A CGI.pm object
containing the data from this query must be passed as a named
parameter:
$output = $select->handle_get_node(query => $query);
http://rt.cpan.org
sam@tregar.com. Please
include the version of the module and a complete test case that
demonstrates the bug.
| HTML-PopupTreeSelect-Dynamic documentation | view source | Contained in the HTML-PopupTreeSelect-Dynamic distribution. |