Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

11. Beispielanwendung > Editieren

Editieren

Für das Anzeigen des Dokuments in einer bestimmten Form bietet sich eine Show-Funktion an. Wie der Name schon verrät, sind diese Funktionen für das Darstellen von Dokumenten gedacht. Sie können weder andere Dokumente in dieser Funktion laden, noch können Sie irgendwelche Änderungen am Dokument oder an der Datenbank vornehmen. Im Gegenzug sind Show-Funktionen frei von Nebenwirkungen, und die bekannten HTTP-Mechanismen zur Steigerung der Performance (Caching, Loadbalancing etc.) können angewandt werden. Wir verwenden diese Funktion also nur für das »Rendern« unseres Dokuments. Dafür legen wir im Verzeichnis shows die Datei edit.js an.

function(doc, req) {
  // !json templates.edit
  // !code vendor/couchapp/path.js
  // !code vendor/couchapp/template.js

  // we only show html
  return template(templates.edit, {
    doc : doc,
    docid : toJSON((doc && doc._id) || null),
    assets : assetPath()
  });
}

  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial