Skip to Content
JAVASCRIPT網頁應用程式設計
book

JAVASCRIPT網頁應用程式設計

by Alex MacCaw
January 2013
Intermediate to advanced
332 pages
5h 23m
Chinese
GoTop Information, Inc.
Content preview from JAVASCRIPT網頁應用程式設計
檢視器(View)與模版(Template
|
81
就可以利用 jQuery 的選取項來更新檢視器內容,或是將檢視器裡的一些網頁元件,設定
為顯示或隱藏狀態:
$("#views div").hide();
var container = $("#views .user");
container.find("span").text(data.name);
container.show();
這是動態產生網頁元件的較佳做法,因為這種做法能將檢視器和控制器之間的權責,劃
分得更加清楚。
模版(Template
如果你曾經在 HTML 程式碼裡面,安插過一些伺服器端程式語言的變數,相信應該不會
對模版的概念感到陌生。雖然目前可供選用的模版函式庫種類相當的多(該選用哪種模
版函式庫,應依目前選用的 DOM 函式庫而定),但它們所使用的語法其實都大同小異。
本章稍後,將會更詳細的介紹一些模版函式庫語法。
JavaScript 模版的重點在於:讓你可以在 HTML 程式碼裡面安插一些模版變數、將模版
變數和某個 JavaScript 物件整合在一起(也就是利用 JavaScript 物件的屬性值,來置換
這些模版變數的值)。整體而言,JavaScript 模版的運作方式,和其他程式語言的模版函
式庫(像:PHP SmartyRuby ERB,以及 Python string formatting)並無二致。
本章稍後在解說模版概念時,所採用的範例程式碼是搭配 jQuery.tmpl 函式庫(
http:// ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

初めてのJavaScript 第3版 ―ES2015以降の最新ウェブ開発

初めてのJavaScript 第3版 ―ES2015以降の最新ウェブ開発

Ethan Brown, 武舎 広幸, 武舎 るみ
PHP编程:第4版

PHP编程:第4版

Kevin Tatroe, Peter MacIntyre
Strange Code

Strange Code

Ronald T. Kneusel
Perfecting Your Thinking Skills

Perfecting Your Thinking Skills

MIT Sloan Management Review

Publisher Resources

ISBN: 9789862766811