Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

checkbox perl jquery

By: mamesaye on May 25th, 2012  |  syntax: Perl  |  size: 1.16 KB  |  views: 53  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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>