Advertisement
saasbook

Simple UJS example

Oct 16th, 2012
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 0.60 KB | None | 0 0
  1. <html>
  2. <head>
  3. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"
  4.        type="text/javascript"></script>
  5. <script type="text/javascript">
  6.  
  7.   $(function() {                         // in jQuery, $() appends an onLoad handler to document
  8.     $('#myAlert').click(function () {    // adds an onClick handler to #myAlert
  9.       alert(this.getAttribute('data-message')); return false;
  10.       })
  11.     // we could add other elements' event handlers here
  12.   });
  13. </script>
  14.  
  15. </head>
  16. <body>
  17. <p><a href="#" id="myAlert" data-message="Hello from UJS">Click Here</a></p>
  18.  
  19. </body>
  20.  
  21. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement