Kamis, 19 April 2012

Javascript Framework Mootols


Adalah framework Javascript. Di gunakan untuk memudahkan membangun aplikasi web berbasis Javascript dan Ajax. Mootools dibuat oleh Valerio Proietti.
Pembagian Mootols terdiri dari 2 bagian yaitu
a.       Mootools core adalah core dari mootools
b.       Mootools more adalah plugin dari mootools
c.        Dasar-dasar Mootools
d.       Pada umumnya JavaScript dipakai untuk menjalankan sesuatu ketika sebuah kejadian (event) terjadi misalnya saat tombol diklik, form disubmit, checkbox diklik dan sebagainya.
e.        Contohnya adalah sebagai berikut.
<html>
<head>
   <script>
   function clickMe()
   {
      alert('Terima kasih, Anda telah mengklik link ini');
   }
   </script>
</head>
<body>
<a href="#" onclick="clickMe()">Klik di sini</a>
</body>
</html>
Jika dieksekusi dan link tersebut diklik, fungsi clickMe akan dijalankan dan akan muncul sebuah kotak kecil. Dengan Mootools, Anda bisa membuat fungsi yang serupa namun dengan struktur yang lebih terorganisir.
<html>
<head>
   <script src="mootools.js"></script>
   <script>
   window.addEvent('domready', function () {
      $('clickMe').addEvent('click', function(e){
         e.stop();
         alert('Terima kasih, Anda telah mengklik link ini');
      });
   });
   </script>
</head>
<body>
   <a href="#" id="clickMe"">Klik di sini</a>
</body>
</html>
Mungkin Anda penasaran, apa bedanya dengan skrip yang pertama? Jika dijalankan hasilnya sama seperti skrip sebelumnya.
Mootools mempunyai sebuah event khusus yang dinamakan domready. Event ini berfungsi untuk menangani kejadian ketika Document Object Model (DOM) diakses.
Nah, di dalam domready inilah Anda bisa menuliskan fungsi-fungsi lain untuk menangani event tertentu seperti klik, submit, drag-drop dan sebagainya.
Untuk menangkap event yang dihasilkan oleh suatu object HTML, Anda bisa menggunakan fungsi dollar ($) dengan parameter berupa ID object tersebut. Dalam contoh di atas yaitu$(‘clickMe’).

5 komentar:

  1. David Walsh is Mozilla’s senior web developer, and the core developer for the MooTools
    Javascript Framework. David’s blog reflects his skills in HTML/5, JS and CSS, and offers a ton
    of engaging advice and insight into front-end technologies. Even more obvious is his passion
    for open source contribution and trial-and-error development, making his blog one of the
    most honest and engaging around.
    Website: davidwalsh.name

    BalasHapus
  2. David Walsh is Mozilla’s senior web developer, and the core developer for the MooTools Javascript Framework. David’s blog reflects his skills in HTML/5, JS and CSS, and offers a ton of engaging advice and insight into front-end technologies. Even more obvious is his passion for open source contribution and trial-and-error development, making his blog one of the most honest and engaging around.
    Website: davidwalsh.name

    BalasHapus
  3. David Walsh is Mozilla’s senior web developer, and the core developer for the MooTools Javascript Framework. David’s blog reflects his skills in HTML/5, JS and CSS, and offers a ton of engaging advice and insight into front-end technologies. Even more obvious is his passion for open source contribution and trial-and-error development, making his blog one of the most honest and engaging around.
    Website: davidwalsh.name

    BalasHapus
  4. David Walsh is Mozilla’s senior web developer, and the core developer for the MooTools Javascript Framework. David’s blog reflects his skills in HTML/5, JS and CSS, and offers a ton of engaging advice and insight into front-end technologies. Even more obvious is his passion for open source contribution and trial-and-error development, making his blog one of the most honest and engaging around.
    Website: davidwalsh.name

    BalasHapus
  5. David Walsh is Mozilla’s senior web developer, and the core developer for the MooTools Javascript Framework. David’s blog reflects his skills in HTML/5, JS and CSS, and offers a ton of engaging advice and insight into front-end technologies. Even more obvious is his passion for open source contribution and trial-and-error development, making his blog one of the most honest and engaging around.
    Website: davidwalsh.name

    BalasHapus