The HTML is the foundation
of your UI in any web application, so careful and semantic use of HTML and considered
use of IDs and classes will really help you when it comes to DOM scripting.
CHAPTER 9 n A DYNAMIC HELP SYSTEM 191
Really think about whether you??™re using the correct elements for the content in hand and
be careful not to fall into the trap of ???divitis??? (wrapping everything in
elements and
bloating out your HTML). A nice, clean, and meaningful markup means that, in many cases,
browsers can do much of your work for you. Use
tags to link to content, and to
mark up lists and forms, and buttons to trigger server-side actions. Work with the grain of the
browser instead of misusing elements and then coding around your misuse with JavaScript.
With that said, let??™s get into the code.
Using Layouts for Common Markup
First you need to write the common HTML that will form the layout of your application. In
Ruby On Rails terms, a layout is a means of including common elements in many pages of
your application. You can think of it as the inverse of server-side includes (such as those supported
by many platforms such as PHP and ASP). Instead of defining snippets of common
content that are included into each of your documents, a layout is a common template into
which page-specific content is injected (see Figure 9-2).
Figure 9-2. The differences between includes and layouts
Although layouts are a Ruby On Rails feature, many other frameworks, including
CakePHP, CodeIgniter, and Django, have an equivalent.
Pages:
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270