Skip to content

Commit

Permalink
finished the editing of the first draft of ch8
Browse files Browse the repository at this point in the history
  • Loading branch information
yfain committed Nov 13, 2012
1 parent 2cf6fea commit 47d08e6
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 74 deletions.
Binary file added 1_Desktop/02_JavaScript/aptana_error.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 8 additions & 4 deletions 1_Desktop/02_JavaScript/ch2_advancedjs.asc
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ TIP: You can also use +console.info()+, +console.debug()+, and +console.error()+

Now comes the chicken or the egg dilemma. What should we explain first - functions or objects? Understanding of objects is needed for some of the function code samples and visa versa. We'll start with simple function use cases, but will be switching to objects as needed.

Many of the readers can have experience with object-oriented languages like Java or C#, where classes can include _methods_ implementing required functionality. Then these methods can be invoked with or without instantiation of the objects. If a JavaScript object includes functions they are also called _methods_. But JavaScript functions don't have to belong to an object. You can just declare a function and invoke it. Just like this:
Many of the readers can have experience with object-oriented languages like Java or C#, where classes can include _methods_ implementing required functionality. Then these methods can be invoked with or without instantiation of the objects. If a JavaScript object includes functions they are called _methods_. But JavaScript functions don't have to belong to an object. You can just declare a function and invoke it. Just like this:

[source,javascript]
----
Expand Down Expand Up @@ -369,24 +369,28 @@ var p = { lastName: "Roberts",
p.makeAppointment();
----

===== ss


===== Creating Objects Based on Other Objects



=== JavaScript and HTML Elements


After learning all these facts and techniques about the language you might be eager to see "the real use of JavaScript" – manipulating HTML elements of Web pages, which most of the people use JavaScript for. This
is correct, at least today. In this section we'll be doing exactly this – applying JavaScript code to HTML elements.

First let's consider the operations we need to be able to perform inside the Web page:
First let's consider the operations your application needs to be able to perform inside the Web page:

* Programmatically finding the required element by id, type, or a CSS class.
* Changing styles of the elements (show, hide, apply fonts and colors et al.)
* Processing events that may happen to HTML elements (+click+, +mouseover+ et al.)
* Dynamically adding or removing HTML elements from the page or changing their contents
* Communicating with the server side, e.g. form submission or making AJAX requests for some data from the server

You’ll need to understand how to perform these operations from JavaScript. Even if you’ll be using one of the popular frameworks, you'll be performing the same operations applying the syntax prescribed
by your framework of choice. So let's get started.
You need to understand how to perform these operations from JavaScript. Even if you’ll be using one of the popular frameworks, you'll be performing the same operations applying the syntax prescribed by your framework of choice. So let's get started.

=== Styling Web Pages with CSS

Expand Down
Loading

0 comments on commit 47d08e6

Please sign in to comment.