I am new to CanJS and was trying to learn via tutorials.. Once place where I got stuck was when I converted the todo tutorial code to use table instead of UL/LI combination.
May be I am making some very small mistake.. but could not find out the same for last 3 days.. Can someone help out?
The jsFiddle for the short version of todo tutorial (which now uses tables) is here where you can see the problems.
The crux of the code from ejs is here..
<script type='text/ejs' id='todosEjs'>
<table border="1">
<thead>
<tr>
<th>id</th>
<th>name</th>
<th>status</th>
</tr>
</thead>
<tbody>
<!-- bind to changes in the todo list -->
<% this.each(function( todo ) { %>
<!-- add the todo to the element's data -->
<tr <%= (el) -> el.data('todo',todo) %>>
<td>
<input type="checkbox" <%= todo.attr('complete') ? 'checked' : '' %>>
</td>
<td><%= todo.attr('name') %></td>
<td><%= todo.attr('id') %></td>
</tr>
<% }) %>
</tbody>
</table>
</script>
Looking forward towards helping hands :-)
UPDATE: This was the result of a bug which is now fixed
It looks as if the comments are the problem here. Removing them makes it work, see the updated Fiddle:
<table border="1">
<tr>
<th>id</th>
<th>name</th>
<th>status</th>
</tr>
<% this.each(function( todo ) { %>
<tr <%= (el) -> el.data('todo',todo) %>>
<td>
<input type="checkbox" <%= todo.attr('complete') ? 'checked' : '' %>>
</td>
<td><%= todo.attr('name') %></td>
<td><%= todo.attr('id') %></td>
</tr>
<% }) %>
Related
SyntaxError: Unexpected token ')' in C:\Users\hp\short.nner\views\index.ejs while compiling ejs
If the above error is not helpful, you may want to try EJS-Lint:
https://github.com/RyanZim/EJS-Lint
at new AsyncFunction (<anonymous>)
at Template.compile (C:\Users\hp\short.nner\node_modules\ejs\lib\ejs.js:661:12)
at Object.compile (C:\Users\hp\short.nner\node_modules\ejs\lib\ejs.js:396:16)
at handleCache (C:\Users\hp\short.nner\node_modules\ejs\lib\ejs.js:233:18)
at tryHandleCache (C:\Users\hp\short.nner\node_modules\ejs\lib\ejs.js:272:16)
at View.exports.renderFile [as engine] (C:\Users\hp\short.nner\node_modules\ejs\lib\ejs.js:489:10)
at View.render (C:\Users\hp\short.nner\node_modules\express\lib\view.js:135:8)
at tryRender (C:\Users\hp\short.nner\node_modules\express\lib\application.js:640:10)
at Function.render (C:\Users\hp\short.nner\node_modules\express\lib\application.js:592:3)
at ServerResponse.render (C:\Users\hp\short.nner\node_modules\express\lib\response.js:1012:7)
at C:\Users\hp\short.nner\server.js:49:17
at processTicksAndRejections (node:internal/process/task_queues:93:5)
Here's my code:
<%=Url.forEach(shortUrl => { %>
<tr>
<td>
<a href="<%= shortUrl.full %>">
<%= shortUrl.full %>
</a>
</td>
<td>
<a href="<%= shortUrl.short %>">localhost:3000/<%= shortUrl.short %></a
>
</td>
<td><%= shortUrl.clicks %></td>
<td><%= shortUrl.GivenEmail %>
</tr>
<% }) %>
I really don't know why I am getting this error please help.
I did give the Url as an option to my ejs but I get this strange error on running it.
I wasn't able to fully test your code yesterday because I was on mobile.
The problem is actually coming from the = in the beginning of <%=Url.forEach(shortUrl =>. Just remove it like this should work:
<% Url.forEach(shortUrl => { %>
<tr>
<td>
<a href="<%= shortUrl.full %>">
<%= shortUrl.full %>
</a>
</td>
<td>
<a href="<%= shortUrl.short %>">localhost:3000/<%= shortUrl.short %></a
>
</td>
<td><%= shortUrl.clicks %></td>
<td><%= shortUrl.GivenEmail %>
</tr>
<% }) %>
That should dismiss the error.
I have two tables for my inventory first is the Item List then the Item Info
I bind the Item List to a HTML Table the add a button for each row the purpose of the button is to show the Item Info or table via modal
I have already done the table and modal design but i cant get or pass the Item ID for my Item List to my modal
can anyone help me i'm kind a new in HTML (noob hir :3)
<thead>
<tr>
<th class="text-center">Item ID</th>
<th class="text-center">Particular</th>
</tr>
</thead>
<tbody class="searchable">
<% List<Inventory.MODEL.adminView>x = new List
<Inventory.MODEL.adminView>(); Inventory.BAL.ItemBAL z = new Inventory.BAL.ItemBAL(); x = z.getAdminView().ToList(); foreach (var item in x) {%>
<tr>
<td>
<%=i tem.ID %>
</td>
<td>
<%=i tem.Particulars %>
</td>
<%}%>
<td class="text-center">
<span class='glyphicon glyphicon-info-sign'></span>
</td>
</tr>
<%} %>
</tbody>
</table>
</div>
</div>
<div id="Modal" class="modal fade">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Item Inventory</h4>
</div>
<div class="modal-body">
<table class="table table-hover table-bordered">
<thead>
<tr>
<th class="text-center">Item ID</th>
<th class="text-center">Total Quantity</th>
</tr>
</thead>
<tbody>
<% iteminvents(); %>
</tbody>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
that's my code, anyone can advice or can help me ?
Pass this in myFunction() as argument , As myFunction(this)
and inside function you can get ItemId as below. I have used jquery here.
function myFunction(sender)
{
var CurrentRow=$(sender).closest("tr");
var ItemId=$("td:eq(0)",$(CurrentRow)).html(); // Can Trim also if needed
}
I am trying to use TinyMCE to allow my users to modify a handlebars report template. The template contains several elements that are not valid to TinyMCE and they are being moved around. See the {{#each data}} and {{/each}}
Here is good HTML code for my handlebars template:
<table class="table table-bordered">
<thead>
<tr>
<th><h4>Item</h4></th>
<th><h4 class="text-right">Quantity</h4></th>
<th><h4 class="text-right">Rate/Price</h4></th>
<th><h4 class="text-right">Sub Total</h4></th>
</tr>
</thead>
<tbody>
{{#each Details}}
<tr>
<td>{{Item}}<br><small>{{Description}}</small></td>
<td class="text-right">{{Quantity}}</td>
<td class="text-right">{{Rate}} {{UnitOfMeasure}}</td>
<td class="text-right">{{Amount}}</td>
</tr>
{{/each}}
</tbody>
</table>
After I past the code into TinyMCE, it results to the following:
{{#each Details}}{{/each}}
<table class="table table-bordered">
<thead>
<tr><th>
<h4>Item</h4>
</th><th>
<h4 class="text-right">Quantity</h4>
</th><th>
<h4 class="text-right">Rate/Price</h4>
</th><th>
<h4 class="text-right">Sub Total</h4>
</th></tr>
</thead>
<tbody>
<tr>
<td>{{Item}}<br /><small>{{Description}}</small></td>
<td class="text-right">{{Quantity}}</td>
<td class="text-right">{{Rate}} {{UnitOfMeasure}}</td>
<td class="text-right">{{Amount}}</td>
</tr>
</tbody>
</table>
Has anyone ran across a plugin or something else that may help me?
I just ran into this... I have an order confirmation email that I need to be configurable with a list of order items in a table; same issue.
I did just realize I probably shouldn't be using tables anyway, since they are not responsive, but I ultimately was able to solve the problem with HTML comments, like this:
<tr style="font-weight: bold;">
<td style="width: 145px;">Qty</td>
<td>Item</td>
<td>Unit Price</td>
<td>Total</td>
</tr>
<!--{{#order.line_items}} -->
<tr repeat="">
<td style="width: 145px;">{{quantity}}</td>
<td>{{product.name}}</td>
<td>{{currency unit_price}}</td>
<td>{{currency total}}</td>
</tr>
<!--{{/order.line_items}} -->
<tr>
<td style="width: 145px;"> </td>
<td> </td>
<td><strong>Subtotal:</strong></td>
<td>{{currency order.subtotal}}</td>
</tr>
I was able to use a custom attribute on my Element and use:
<tr repeat="{{#each Details}}">
</tr repeat="{{/each}}">
For a given table, I'd like to get the below
total number of rows
able to iterate over by row and column
using the Java Driver. I tried the option mentioned here with no luck.
Below is the HTML for table
<div id="hawkMessageCodeTable" class="ui-datatable ui-widget">
<table>
<thead>
<tr>
<th id="hawkMessageCodeTable:j_idt49" class="ui-state-default">
<div class="ui-dt-c">
<span>Code</span>
</div>
</th>
<th id="hawkMessageCodeTable:j_idt51" class="ui-state-default">
<div class="ui-dt-c">
<span>Message</span>
</div>
</th>
</tr>
</thead>
<tbody id="hawkMessageCodeTable_data" class="ui-datatable-data ui-widget-content">
<tr data-ri="0" class="ui-widget-content ui-datatable-even">
<td>
<div class="ui-dt-c">
9005
</div>
</td>
<td>
<div class="ui-dt-c">
Initial Fraud Alert on File
</div>
</td>
</tr>
<tr data-ri="1" class="ui-widget-content ui-datatable-odd">
<td>
<div class="ui-dt-c">
9003
</div>
</td>
<td>
<div class="ui-dt-c">
Security Alert or consumer statement on file relates to true name fraud or credit fraud
</div>
</td>
</tr>
<tr data-ri="2" class="ui-widget-content ui-datatable-even">
<td>
<div class="ui-dt-c">
2501
</div>
</td>
<td>
<div class="ui-dt-c">
Input/File (Current/Previous) Address Has Been Used (#) Times In The Last (30,60,90) Days On Different Inquiries
</div>
</td>
</tr>
<tr data-ri="3" class="ui-widget-content ui-datatable-odd">
<td>
<div class="ui-dt-c">
9004
</div>
</td>
<td>
<div class="ui-dt-c">
Active Duty Alert on File
</div>
</td>
</tr>
</tbody>
</table>
</div>
I have implemented a similar function with sahi for ruby. To answer your questions:
rowLen = table.fetch("rows.length").to_i
Loop through all the cells with:
#browser.cell(table,rowIndex,colIndex).exists?()
You can find the corresponding api for sahi java
have an action that generates active vacancies. The code is below;
public ViewResult OpenVacancies()
{
var openvacancies = db.GetActiveVacancies();
return View(openvacancies);
}
I want to use this list on several pages so i guess the best thing to use is html.renderaction (please correct me if i am wrong here).
Please note that the view and .ascx control are in an Area.
I then created a view by right clicking inside the action and create a .ascx and a strongly typed view of Vacancy. I chose a view content of "List".
I then added this line to the required page;
Please note that the view and .ascx control are in an Area.
The error i got is;
The type or namespace name 'Vacancy' could not be found (are you missing a using directive or an assembly reference?)
the .ascx code is below;
>" %>
<table>
<tr>
<th></th>
<th>
VacancyID
</th>
<th>
JobTitle
</th>
<th>
PositionID
</th>
<th>
LocationID
</th>
<th>
JobDescription
</th>
<th>
JobConditions
</th>
<th>
Qualifications
</th>
<th>
RequiredSkills
</th>
<th>
Certifications
</th>
<th>
AdvertDate
</th>
<th>
AdvertExpiryDate
</th>
<th>
Status
</th>
<th>
StaffLevel
</th>
<th>
LineManagerEmail
</th>
<th>
ApprovalFlag
</th>
<th>
RequisitionDate
</th>
</tr>
<% foreach (var item in Model) { %>
<tr>
<td>
<%= Html.ActionLink("Edit", "Edit", new { id=item.VacancyID }) %> |
<%= Html.ActionLink("Details", "Details", new { id=item.VacancyID })%> |
<%= Html.ActionLink("Delete", "Delete", new { id=item.VacancyID })%>
</td>
<td>
<%= Html.Encode(item.VacancyID) %>
</td>
<td>
<%= Html.Encode(item.JobTitle) %>
</td>
<td>
<%= Html.Encode(item.PositionID) %>
</td>
<td>
<%= Html.Encode(item.LocationID) %>
</td>
<td>
<%= Html.Encode(item.JobDescription) %>
</td>
<td>
<%= Html.Encode(item.JobConditions) %>
</td>
<td>
<%= Html.Encode(item.Qualifications) %>
</td>
<td>
<%= Html.Encode(item.RequiredSkills) %>
</td>
<td>
<%= Html.Encode(item.Certifications) %>
</td>
<td>
<%= Html.Encode(String.Format("{0:g}", item.AdvertDate)) %>
</td>
<td>
<%= Html.Encode(String.Format("{0:g}", item.AdvertExpiryDate)) %>
</td>
<td>
<%= Html.Encode(item.Status) %>
</td>
<td>
<%= Html.Encode(item.StaffLevel) %>
</td>
<td>
<%= Html.Encode(item.LineManagerEmail) %>
</td>
<td>
<%= Html.Encode(item.ApprovalFlag) %>
</td>
<td>
<%= Html.Encode(String.Format("{0:g}", item.RequisitionDate)) %>
</td>
</tr>
<% } %>
</table>
<p>
<%= Html.ActionLink("Create New", "Create") %>
</p>
First, if you simply want to reuse your view on multiple pages, you should be using a shared partial view (place it in the Shared folder) with <% Html.RenderPartial("OpenVacancies"); %>.
Second, based on your code snippet, your partial view doesn't appear to be strongly typed. Instead of
<%# Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
you will want something like this:
<%# Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<Vacancy>>" %>