- MooTools 1.2 Beginner's Guide
- Jacob Gube Garrick Cheung
- 341字
- 2021-04-01 13:33:35
Chapter 2. Writing JavaScript with MooTools
Using MooTools means you'll be coding in a web application framework that excels in object-oriented programming and JavaScript best practices. Modern development principles, such as unobtrusive JavaScript programming and object-based logic is the bread and butter of MooTools.
For example, modern development practices dictate that we separate our site's functional and behavioral layers (server-side and client-side scripts) from our site's content structural layer (HTML markup). This concept is known as unobtrusive JavaScript, and we'll delve into this best practice here in this chapter. You'll see one of the more important ways of how MooTools makes us write better JavaScript.
But we're going to be covering more than just unobtrusive JavaScript. We're going to work with classes, which is the design pattern of the entire MooTools framework.
MooTools is structured into classes. In programming, a class is simply a template of an object. A class can contain many methods or properties such as normal variables or even references to other classes and objects.
To understand how to write great MooTools code that adheres to best practices, you have to understand its fundamental structure and the concept of classes, which I must admit, can be confusing and hard to grok.
If you know another programming language, especially an object-oriented one, or a pseudo-object-oriented one like PHP (this is where I learned the concept of a class), then the stuff we'll discuss here will look very familiar to you. You can then compare and contrast the difference in syntax of classes in your particular language. As an example, for you PHP folks out there, in PHP 5, we have the
__construct()
function, which you'll soon see, is exactly like theinitialize
method of a MooTools class.
In this chapter we shall:
- Learn how MooTools helps us write unobtrusive JavaScript
- Work with classes by creating our own class
- See how MooTools works by exploring a couple of classes
- Learn about the concept of chainability by working through a simple animation example
So let's get on with it!
- Excel函數(shù)、公式、圖表、數(shù)據(jù)處理從新手到高手
- 微信小程序開發(fā)入門與實踐
- Apache Roller 4.0 – Beginner's Guide
- SPSS統(tǒng)計分析從基礎(chǔ)到實踐
- Django 1.0 Template Development
- 中文版After Effects 2022基礎(chǔ)教程
- 正則表達(dá)式必知必會(修訂版)
- 平面設(shè)計制作標(biāo)準(zhǔn)教程(微課版 第2版)
- 高等院校電腦美術(shù)教材:CorelDRAW X7中文版基礎(chǔ)教程
- After Effects 2022從新手到高手
- Elasticsearch數(shù)據(jù)搜索與分析實戰(zhàn)
- 中文版Photoshop CS5平面設(shè)計實用教程(第2版)
- Mobile Web Development
- SAP Business ONE Implementation
- Network Administration with FreeBSD 7