in reply to Re^3: cgi scripts running javascript and passing control back and forth
in thread How to allow a user to reorder rows from a database using a web form?
The first template looked like this:
and then the main part of my CGI script looks like this:<!-- ticket.tmpl --> <html> <head> <title>Open Tickets</title> </head> <body> <h1>Open Tickets</h1> <table> <!-- TMPL_LOOP NAME=ROWS --> <tr> <td><!-- TMPL_VAR NAME=ID --></td> <td><!-- TMPL_VAR NAME=SUBJECT --></td> <td><!-- TMPL_VAR NAME=REQUESTORS --></td> </tr> <!-- /TMPL_LOOP --> </table> </body> </html>
This worked as expected. Then, I tried modifying the template to use the jquery-ui stuff as follows:my @select_fields = qw( id subject requestors ); my $template = HTML::Template->new( filename => 'ticket-short.tmpl' ); print $q->header(); foreach my $org ( keys %orgs ) { my $sql = "select " . join( ", ", @select_fields ) . " from tickets where $orgs{$org}"; my $sth = $dbh->prepare($sql) or die( "Cannot prepare: " . DBI::er +rstr() ); $sth->execute() or die( "Cannot execute: " . DBI::errstr() ); # Prepare a data structure for HTML::Template my $rows; push @{$rows}, $_ while $_ = $sth->fetchrow_hashref(); if ( defined @{$rows} ) { $template->param( ROWS => $rows ); } } print $template->output();
But, I can't move anything around on the screen. It seems like I'm still missing something or doing something wrong.<!-- ticket-short.tmpl --> <html> <script type=”text/javascript” src=”js/jquery-1.4.4.min.js”></scri +pt> <script type=”text/javascript” src=”js/jquery-ui-1.8.7.custom.min. +js”></script> <script> $(function() { $( "#sortable" ).sortable(); $( "#sortable" ).disableSelection(); }); </script> <style> #sortable { list-style-type: none; margin: 0; padding: 0; width: 6 +0%; } #sortable li { margin: 0 3px 3px 3px; padding: 0.4em; padding-left +: 1.5em; font-size: 1.4em; height: 18px; } #sortable li span { position: absolute; margin-left: -1.3em; } </style> <head> <title>Open Tickets</title> </head> <body> <h1>Open Tickets</h1> <div class="tickets"> <ul id="sortable"> <!-- TMPL_LOOP NAME=ROWS --> <li class="ui-state-default"><span class="ui-icon ui-icon- +arrowthick-2-n-s"></span><!-- TMPL_VAR NAME=ID --> - <!-- TMPL_VAR NA +ME=SUBJECT --> - <!-- TMPL_VAR NAME=REQUESTORS --></li> <!-- /TMPL_LOOP --> </ul> </div> </body> </html>
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^5: cgi scripts running javascript and passing control back and forth
by marto (Cardinal) on Jan 06, 2011 at 00:03 UTC | |
by yaconsult (Acolyte) on Jan 10, 2011 at 00:24 UTC | |
by marto (Cardinal) on Jan 10, 2011 at 09:47 UTC | |
Re^5: cgi scripts running javascript and passing control back and forth
by marto (Cardinal) on Jan 06, 2011 at 13:32 UTC | |
by yaconsult (Acolyte) on Jan 10, 2011 at 00:32 UTC |