how to fill with page with json.data with better looking code? - json

until now, this is kind of how i fill my page with data i received from $.getJSON.
collection.push("div class='item'><img src='" + items[i].imgurl + "' /><h1>" + items[i].itemname + "</h1><p id='desription" + i + "'>" + items[i].infotxt + "</p></div>);
those lines look so terrible inside my editor, that i wonder if this is even the right way to do it...
might there something like a class costructor for this or anything like that?
thank you very much

Have you looked into the jquery-json plugin?
https://code.google.com/p/jquery-json/

Related

Putting HtmlWidget elements in a paragraph

May I know how to put the elements I get from HtmlWidget(allwordlist![0].ivakavakayagataki.toString()), HtmlWidget(allwordlist![0].ivakavakayagataki.toString()), in a paragraph?
I am making a dictionary application and the above HTML render code works but problem is that I cannot seem to find a way to put these two in a paragraph as in side by side like a sentence.
May I get some help un knowing how to do this please.
Thanks in advance.
Ok so I made it work.
So I first made this function and not that <p> tags so the problem thats was making my HtmlWidget statement not inline and having line breaks was because of the p tag so I first took it out.
Widget mergehtml(String html1, String html2,){
html1 = html1.replaceAll("<p>", "").replaceAll("</p>", "");
html2 = html2.replaceAll("<p>", "").replaceAll("</p>", "");
String mergedHtml = "<p style='font-size:18px;'>" + html1 + " " + "[" + html2 + "], " + "</p>" ;
return HtmlWidget(mergedHtml);
}
and then I called it and put my two variables there.
mergehtml("${allwordlist![0].tina}","${allwordlist![0].itavi}",)
it then started working inline.
Thanks :)

multi-line in aurelia component html attribute property

This is a weird question about possibly embedding a string in an aurelia html file within the attribute tag but I would like to keep my tab and line formatting.
So, in my TS file I have the following:
this.queryDateStart += "type=EntityOne&dateQueryString=";
this.queryDateStart += "" +
"eOr( " +
"eAnd( " +
"eAnd( facetName:isExcluded AND facetValue:No );" +
"dAnd( facetName:deadlineDate AND "+ dateRangePredicate + ");" +
"); " +
"dOr( " +
"(facetName:excludedUntilDate AND "+ dateRangePredicate + ")" +
");" +
");"
And instead of having the following:
<section as-element="ab-deadlines" data-query="${queryDateStart}"></section>
I would like to actually pass the literal string from above.
But with the line spaces.
Would that break anything?
So for example ( going to try this today) - in my html file I would put:
<section as-element="ab-deadlines"
data-query="
eOr(
eAnd(
eAnd( facetName:isExcluded AND facetValue:No );
dAnd( facetName:deadlineDate AND ${dateRangePredicate} );
);
dOr(
(facetName:excludedUntilDate AND + ${dateRangePredicate} )
);
);"></section>
About breaking: it shouldn't break anything. In the end, it's just normal HTML attribute, and as long as the spec allows it, it works in Aurelia, as Aurelia works directly, and plainly with HTML elements.
You can see it yourself at this sandbox https://codesandbox.io/s/z20qx0q263

Displaying file JHtml

Can you help please. I am trying to list these outcome in a vertical order, but it keeps horizontally.
document.writeln("Premium ticket cost is " + calcBaseCost("premium", numTickets, baseTicketPrice));
document.writeln("Standard ticket cost is " + calcBaseCost("standard", numTickets, baseTicketPrice));
document.writeln("Budget ticket cost is " + calcBaseCost("budget", numTickets, baseTicketPrice));
Tried <p> </ p> but to no avail
Add a <br/>
so
document.writeln("Premium ticket cost is " + calcBaseCost("premium", numTickets, baseTicketPrice) + "<br/>");
And do that for all the other ones too.
Although I'd recommend you not use document.writeln and instead write the results into a div
<div id='results'></div>
then
document.getElementById('results').innerHTML = "blablabla...";
If I have helped please mark my answer as correct by clicking on the checkmark. Thanks.

Mix html and code asp.net

I'm trying to join two strings but I want them to be divided by a break line.
This is my code:
<td>#(string.Join("<br /> ", report.TimeReportProjects.Select(x => x.Project.ProjectName)))</td>
<td>#(string.Join("<br /> ", report.TimeReportProjects.Select(x => x.Description.Shorten(35))))</td>
<td>#(data.StartHour + ":" + data.StartMinute.ToString("00") + " - " + data.EndHour + ":" + data.EndMinute.ToString("00"))</td>
<td>#(Math.Floor(hours) + ":" + TimeSpan.FromHours(hours).Minutes.ToString("00"))</td>
The "br/>" tag will just be read as a string which is not to strange I assume, I know if i want to mix html code in a code block I should use #: but I am not sure how to use that in this case.
There is a Html.Raw method that should help you. It can be applied like so:
<td>#Html.Raw(string.Join("<br />", report.TimeReportProjects.Select(x => x.Project.ProjectName)))</td>

Show link in html table cell

I'm tring to add a link in my code like below,I have written a javascript function,thing is in UI it has to show data as link.
string str="" + dataTable.Rows[i][j] + ""
Is there a way to show my datatable data as a link in UI?
Reply
assuming that your dataTable[i][j] is the link .. we can simply do this in javascript to create a link
link = '<a href="' + dataTable[i][j] + '" >Link</a>';
then use this string wherever you want.
or as i just saw the updated question
'<td>' + dataTable[i][j] + '</td>'
Where is the start of the anchor (<a ...>) tag? There is only an end one. Try...
<td>{link}</td>