express-flash not showing message until refresh - node.js

I have express-flash installed and working, but only after I refresh the page I was redirected to. My controllers are using flash like so
req.flash("info", "No changes were made.");
res.redirect("/admin/dashboard");
In the view, I am importing a partial that looks like this.
<% if(messages.info) { %>
<div class="modal-content flashModal" id="message-info">
<div class="header">
<span id="closeBtn">×</span>
</div>
<div class="modal-body">
<strong>
<%= messages.info %>
</strong>
</div>
</div>
<% } %>
Not exactly sure what is causing the message to appear only after I have refreshed. It looks like the redirect is happening before the flash message? The documentation seemed straight forward enough but doesn't cover an issue like this. Any help is appreciated.
https://www.npmjs.com/package/express-flash

Try to use render instead of redirect. See if it works.
res.render('dashboard);

Related

How to display image from dynamic path in node ejs

I am trying to display image based on the path I get from database
here's my code
<% cars.forEach(function(car) { %>
<div class="card">
<div class="img">
<img src="images/" +"<%=car.Img_path %>">
</div>
</div>
<% }); %>
I also tried <img src="images/<%=car.Img_path %>"> but not working.
Can Anyone suggest how to render image.
Thanks In Advance.
<img src="images/<%=car.Img_path %>"> works. My issue was i didn't included Img_path in car model.
whoever may get this type of issue make sure you have included that field in model otherwise you will have data in database for but you wont get it in your application

ejs with progress bar

How to define or update style="width:<%=MettingPer %>;" for progress bar in ejs
<li class="list-group-item d-flex justify-content-between align-items-center">
Meeting
<div class="progress">
<div class="progress-bar progress-bar-striped bg-success progress-bar-animated" role="progressbar" style="width: 75%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100">
<%=MettingPer %>%</div>
</div>
</li>
EJS is rendered on the server, not the browser, so EJS has no idea what document is since that's something that's only defined in the browser.
So for this you need to load your page completely on the client side with zero value.
Then complete it according to the instructions in JavaScript.
And as soon as you receive a response from the server, complete and hide it with a little delay.

ejs express nodejs onclick show details

i built up a nodejs app using express and ejs as template engine. i can show a list of articles in a page but i don't know how to show detail of article when i click on the item. using Angular 4 you can use components and inject componets on the same page showing details in one compement when you click the item in the other one. i was wondering if it is possible to achieve same goal with ejs
<div class="container">
<div class="row">
<div class="col-lg-4">
<% items.forEach(item){%>
<ul>
<li><%=item%></li>
</ul>
<% } %>
</div>
<div class="col-lg-8>[here details of article]</div>
</div>
</div>

What´s the meaning of this exception and how can I solve it?

I´m working in a Windows App but when I want to add a toolTip I get this exception: HierarchyRequestError. I´ve checked if all my tags are properly typed and it seems that there is no problem with them. Any ideas?
<div id="wrapper" data-win-control="WinJS.UI.Tooltip" data-win-options="{contentElement:'info'}">
<img src="images/news.jpg" alt="Donald Trump">
</div>
<section class="info-wrapper">
<div id="info">
<video controls src="videos/info.wmv"></video>
</div>
</section>
Nevermind, I can´t use a dash. I changed it for an underscore and it worked.

How to link to an entry in a channel in expressionengine?

I have the following code
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
{exp:channel:entries channel="static" sort="asc" dynamic="off"}
<li>{title}</li>
{/exp:channel:entries}
</ul>
</div><!--/.nav-collapse -->
Which is looping through a channel I have for static pages on my website. Technically it is showing all the stuff it should do. This is the code it outputs:
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li>Small Builders</li>
</ul>
</div>
However, when I click the link it gives me a white page. I have the htaccess from the documentation set up. I'm new to ExpressionEngine. Am I missing something completely obvious? I just want to link the the entry I've created.
If you try to go to abc.com/index/small-builders does it work? (added index)
I don't know if you're hiding index in the url or not but that can cause it.
The way I fixed this was the enable the Pages plugin on ExpressionEngine. Where I'm using ExpressionEngine 3.0.5 the plugin isn't installed/activated by default like it is on EE2.
Once this was activated I was able to assign templates and url structure no problem.
guess your post would be better on the expressionengine.stackexchange.com site.
Post it there and i´ll have a look if i can explain this to you

Resources