Losing ListView formatting when HTML is passed to a <div>
Hello:
I am still learning js and jQuery. I ran across this issue I'm hoping someone can point me in the right direction.
I have a function in my js file that takes some data and dynamically combines it with HTML and passed to a div in my HTML doc so it can be displayed. Here is that function:
- function fnShowClassesTable(data) {
- var str = "<ul data-role='listview' data-inset='true'>";*/
- str += "<ul data-role='listview' data-inset='true'>"; // Build a string of HTML; using a <table>
- str += "<li data-role='list-divider' role='heading'>My Active Programs</li>" // A Row in the Table with Headings
- for(var i = 0; i < data.length; i++) { // For "x" number of times-worth of Data...
- // Build a row at a time of data
- str += "<li><a href='#' data-transition='slide'>" + data[i].doc._id +
- ", " + data[i].doc.cName +
- " - " + data[i].doc.cInst +
- "</a></li>";
- }
- str += "</ul>";
- $elDivShow.html(str); // Render the string as HTML on-screen
- $elDivShow.hide().fadeIn(250);
- }
In my HTML doc, the function is called to display with a simple "<div id="divShow"></div>"
It works to display the data, however it doesn't have the formatting I expected with the jQuery ListView. To show what I mean, below is a screenshot of how it renders. The top list is how it renders, the bottom list is where I hard-coded what I wanted it to look like.
Is it having this issue because it's being passed through a div? I'm new to all this so just looking for some pointers.
I am thinking it's not my CSS, since I'm not specifically tweaking this or any other ListView.
Any input is greatly appreciated!