Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to properly use partial views in express with ejs?
    primarykey
    data
    text
    <p>I have a web app were the entire layout remains constant except for one <code>&lt;div&gt;</code>. Currently, I'm just using routes to handle links and it seems like quite a waste to reload the rest of the <code>layout.ejs</code> file where the only thing I wish to change is my <code>&lt;div&gt;</code>.</p> <p>What would I have to change in my <code>layout.ejs</code> file? Here is my current file:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lan="en"&gt; &lt;head&gt; &lt;title&gt;&lt;%= title %&gt;&lt;/title&gt; &lt;link rel="stylesheet" href="/stylesheets/reset.css"&gt; &lt;link rel='stylesheet' href='/stylesheets/style.css' /&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"&gt;&lt;/script&gt; &lt;script src="/nowjs/now.js"&gt;&lt;/script&gt; &lt;script src="/javascripts/chat.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="wrapper"&gt; &lt;div id="header"&gt; &lt;/div&gt; &lt;div id="chat"&gt; &lt;input type="text" id="text-input"&gt; &lt;input type="button" value="Send" id="send-button"&gt; &lt;/div&gt; &lt;div id="content"&gt; &lt;%- body %&gt; &lt;/div&gt; &lt;div id="rooms"&gt; &lt;/div&gt; &lt;div id="footer"&gt; &lt;div id="footer_links"&gt; &lt;a href="/"&gt;Home&lt;/a&gt; | &lt;a href="/about"&gt;About&lt;/a&gt; | &lt;a href="/contact"&gt;Contact&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>I was thinking about using AJAX to use this, but I've heard some good things about using partial views. I'm just not sure at all about how to set this up. Also, I've heard that it's possible to use WebSockets with partial views instead of AJAX. Is this a good idea, or even possible?</p> <p>Sorry this may be straightforward. I'm having a difficult time with the documentation.</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload