I need "input" a script in my .ejs file like that:
<% results.forEach(function(element) {
var atuador = element.atuador;
var status = element.status;
if (atuador === 'QTD1LAMP'){
if (status === 'ON'){
$('#QTD1LAMP').bootstrapToggle('on');
} else {
$('#QTD2LAMP').bootstrapToggle('off');
}
} else if (atuador === "QTD2LAMP"){
if (status === "ON"){
$('#QTD2LAMP').bootstrapToggle('on');
} else {
$('#QTD2LAMP').bootstrapToggle('off');
}
}
})
%>
When i will toogle my button inside my template, for each result i will receive. How can i do that?
i think you misunderstand ejs.
script inside <% ... %>
block must be node.js script, not front-end script
if you want to embed front-end script to ejs file, just simply do like this
<script>
// add script front-end here
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.