NAME
    HTML::JQuery - JQuery for Perl programmers

DESCRIPTION
    HTML::JQuery acts as a bridge between Perl and JQuery/Javascript. It
    enables Perl programmers to do as much Javascript as they can using
    Perl. You can create modals, key sequences and even build javascript
    functions using Perl subroutines. The aim is simple: More Perl, less
    Javascript.

SYNOPSIS
Inject Javascript/JQuery into your web apps using Perl.
        my $j = HTML::JQuery->new;
    
        # build a javascript function that injects pure javascript,
        # HTML::JQuery generated javascript, or both.
        $j->function(myFuncName => sub {
            my $modal = $j->modal({
                title   => 'My Modal Title',
                message => 'The content inside my modal',
            });
            qq {
                alert('We can inject pure javascript like this');
                $modal
            };
        });

    In the above example, when myFuncName() is called an alert box will
    open, then the modal We can call it using an event handler.. yeah, we
    can do this with Perl, too.

        $j->onClick({ class => 'button', event => $j->callFunc('myFuncName') });

    So if we add a link, like <a class="button" href="#">Click Me to
    activate myFuncName</a> It will run our newly created function.

METHODS
  html
    Returns the complete JQuery/Javascript code that the module generates
    for you. It also includes the .ready() feature so you don't need to
    worry about that either. It checks to see if init() is a function, and
    if so, runs it.

  modal
    Generates a simple modal window. The returned string is
    $('#modal_name').dialog('open'); This method needs to be fixed as it's a
    bit picky with the title. The title is used as the modals id.

        $j->modal({
            title   => 'My Modal Title',
            message => 'The content of my modal',
            slide   => 1, # gives it a cool "slide" effect when it opens
        });

  keystrokes
    This method uses the jquery.keystrokes plugin. The syntax is extremely
    easy to use and works exactly as expected. Easily create events based on
    key presses.

        $j->keystrokes({
            keys        => [qw/ctrl+alt c/],
            success     => $j->callFunc('callme'),
        });

    The above code will run whatever is set in success once ctrl+alt then m
    is pressed. If you need to use arrow keys, try this.

        $j->keystrokes({
            keys        => ['arrow left', 'arrow down', 'arrow right', 'a', 'c'],
            success     => 'alert("Ryu says: Hadouken!");',
        });

  callFunc
    Calls a Javascript function so you can use it in other events, ie:
    onClick It also checks to make sure it's a valid function, and if not
    returns false

        $j->callFunc(funcName);

  onClick
    Create an onClick event. You decide what element the event is for by
    setting id => or class => For example, if you use class => 'button' then
    the event handler will be $('.button') or $('#button') for id =>
    'button'. The other argument is event. Once the onClick is triggered,
    the value in event will be run.

        $j->function(clickMe => sub {
            qq { alert("I have been clicked.. arghhhh"); }
        });
    
        $j->onClick({ id => 'button', event => $j->callFunc('clickMe') });

  innerHtml
    Adds the value of html to the specified class or id element. Similar to
    jQuery's $('element').html(); I really need to add an append also.

        # an empty div in the HTML
        <div id="mydiv"></div>

        # then from Perl
        $j->innerHtml({ id => 'mydiv', html => 'Oh wow! There is text in here now'});

  function
    Builds a standard Javascript function. If you call it 'init' then that
    function will be run automatically once the document has loaded.

        $j->function(init => sub {
            qq{ alert('Your document has loaded'); }
        });

    Javascript functions can be called with $j->callFunc(funcName)

BUGS
Please e-mail bradh@cpan.org
AUTHOR
Brad Haywood <bradh@cpan.org>
COPYRIGHT & LICENSE
    Copyright 2011 the above author(s).

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

