HTML-JQuery

 view release on metacpan or  search on metacpan

lib/HTML/JQuery.pm  view on Meta::CPAN


=head2 rel

Just retrieves the C<rel> attribute from an element.

    rel '.somelink';

=cut

sub rel {
    my $sel = shift;
    $CLASS->jquery_rel($sel);
}

=head2 hide

Similar to C<fadeout>, but without the actual "fade" effect. It simply hides an element, but doesn't permanently remove it. 
It will do a CSS equivalent to C<display:none>.
Like most of these types of functions the second argument is the duration and the third is a callback. Both are optional.

    hide '#test', 1000, function(sub{ alert 'Hidden #test' });

=cut

sub hide {
    my ($sel, $duration, $after) = @_;
    $CLASS->jquery_hide($sel, $duration);
}

=head2 show

The same as C<hide>, only shows the element instead if it's hidden

=cut

sub show {
    my ($sel, $duration, $after) = @_;
    $CLASS->jquery_show($sel);
}

=head2 dom_remove

Completely removes the given element from the DOM. This means it won't be able to be used again once it has been removed, unless you 
reload the page, of course.

    onclick 'div' => sub {
        hide 'this', 2000, function(sub {
            dom_remove 'this'
        });
    };

=cut

sub dom_remove {
    my $sel = shift;
    $CLASS->jquery_remove($sel);
}

=head2 datepicker

Binds a fancy calendar to a specific element (Usually an input field).
If you pass C<<auto =>>> 1 in the hash then it will append C<dateFormat: 'dd/mm/yy', changeMonth: true, changeYear: true> to 
the datepicker options plus anything you specify.

    datepicker '.datefield' => ( dateFormat => 'mm-dd-yy', currentText => 'Now' );

You can see a list of options on jQuery UI's website for datepicker.

=cut

sub datepicker {
    my ($sel, %args) = @_;
    $CLASS->jquery_datepicker($sel, \%args);
}

=head2 appendhtml

Dynamically appends html to a div. 

    innerhtml '#mydiv', 'Hello, World!';

=cut

sub appendhtml {
    my ($sel, $text) = @_;
    $CLASS->jquery_innerhtml($sel, $text);
}

=head1 BUGS

Please e-mail brad@geeksware.net

=head1 AUTHOR

Brad Haywood <brad@geeksware.net>

=head1 COPYRIGHT & LICENSE

Copyright 2011 the above author(s).

This sofware is free software, and is licensed under the same terms as perl itself.

=cut

1;



( run in 0.693 second using v1.01-cache-2.11-cpan-39bf76dae61 )