Advertisement
mamesaye

checkbox perl jquery

May 25th, 2012
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.16 KB | None | 0 0
  1. <%class>
  2. use JSON;
  3. use URI::Escape;
  4. has 'data';
  5. has 'cb'    => ( isa => 'Int');
  6. </%class>
  7.  
  8. <%init>
  9. my $args = eval {
  10.     return from_json(uri_unescape($.data), { ascii => 1});
  11. };
  12. $m->redirect('/login') unless $USER && $USER->{'logged_in'};
  13. $args->{'authors'} = [] unless $args->{'authors'} && ref($args->{'authors'}) eq 'ARRAY';
  14. </%init>
  15.  
  16. <li class="header">
  17.     <p>
  18.         Authors  
  19.         &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
  20.         show sidebar
  21.     </p>
  22. </li>
  23. %  my @author_box = ();
  24.  
  25. % foreach my $a (sort { $a->{'last_name'} cmp $b->{'last_name'} || $a->{'first_name'} cmp $b->{'first_name'} } @{$args->{'authors'}}) {
  26. <li>
  27.     <p>
  28.         <a href="javascript:void(0)" onclick="remove_author(<% $a->{'id'} %>);" class="right icon-small icon-delete-small"></a>
  29.         <% $a->{'last_name'} %>, <% $a->{'first_name'} %> (<% $a->{'initials'} %>)
  30.        
  31.         &emsp;&emsp;&emsp;&emsp;
  32.         <input type="checkbox" name="cb" value="" onclick="$(this).attr('value', this.checked ? 1 : 0)">
  33.     </p>
  34. </li>
  35.  
  36. % }
  37. <li>
  38.     <p>
  39.         <input type="submit" value="Add" class="right" onclick="add_author();"/>
  40.         <input id="new_author" style="width:75%;" />
  41.         <input type="hidden" id="new_author_data" />
  42.     </p>
  43. </li>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement