Login   Register  
PHP Classes
elePHPant
Icontem

File: test_prototype.html

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Jo Giraerts  >  cjEvents  >  test_prototype.html  >  Download  
File: test_prototype.html
Role: Auxiliary data
Content type: text/plain
Description: Test prototype
Class: cjEvents
Handle browser events in PHP
Author: By
Last change:
Date: 2010-08-25 02:15
Size: 2,110 bytes
 

Contents

Class file image Download
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>cjEvents - Test JQuery</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <html>
    <head>
        <title>cjEvents Test</title>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.1.0/prototype.js"></script>
        <script type="text/javascript" src="json2.js"></script>
        <script type="text/javascript" src="events.js"></script>

        <script type="text/javascript">
            function callback1(event)
            {
                var args = event.memo;

                $('event1answer').update('We received a jsevent ('+event.eventName+'). The arguments of the event are: '+args.join(', '));
            }

            function callback2(event)
            {
                var args = event.memo;

                $('event2answer').update('We received a jsevent ('+args[0]+'). The arguments of the event are: '+args.join(', '));
            }

            // Binding the events to their callback
            document.observe("dom:loaded", function() {
                $(document.body).observe('phpevent:jsevent1', callback1);
                $(document.body).observe('phpevent:jsevent2', callback2);
                // listenForPHPEvents();
            });
        </script>
    </head>
  <body>
      <h1>cjEvents Prototype Test</h1>
      <div>
          When clicking 1 of the buttons, you will raise an event that gets sent to PHP. We've set up PHP to receive those events and
          raise a <i>jsevent</i> again to answer for it. The <i>jsevent</i> will be captured by the javascript callbacks on this page,
          and you will see the answer appearing next to the button you clicked.
      </div><br/>

      <input type="button" value="Raise phpevent1" onclick="raisePHPEvent('phpevent1', 'arg1-1', 'arg1-2');" /> <span id="event1answer"></span><br/>
      <input type="button" value="Raise phpevent2" onclick="raisePHPEvent('phpevent2', 'arg2-1', 'arg2-2')" /> <span id="event2answer"></span>
  </body>
</html>