Retrieve record to be edited
Hello:
So I had a function which builds a table in HTML for display on my html document. I wanted to take advantage of jQuery ListView, so I changed it from table to listview. This is the function:
- function fnShowClassesTable(data) {
- var str = "<ul data-role='listview' data-inset='true'>";
- str += "<li data-role='list-divider' role='heading'>My Active Programs</li>"
- for(var i = 0; i < data.length; i++) {
- str += "<li class='btnEditProg'><a href='#' data-transition='slide'><h3>" + data[i].doc._id + "</h3><p id='listviewNoEllipsis'>" + data[i].doc.pDesc + "</p><p class='ui-li-aside'>" + data[i].doc.pStartDate "</p></a></li>";
- }
- str += "</ul>";
- str += "<hr>";
- $elDivShow.html(str).trigger('create');
- $elDivShow.hide().fadeIn(250);
- }
Notice I am building the str variable with the HTML. Now, I also set up some other code to call an edit function when you click on a row in the listview (with the
<li class='btnEditProg'>).
However, the code that was written previously was able to do a .find to populate the edit form is from when it was looking for a table, and it's keying off the <td>. So how would I change this part of my function to find those _id, pDesc, and pStartDate fields?
- function fnUpdateClassPrep(thisObj) {
- console.log(thisObj);
- var $tmpProgName = thisObj.find("td:eq(0)").text(),
- $tmpProgDesc = thisObj.find("td:eq(1)").text(),
- $tmpStartDate = thisObj.find("td:eq(2)").text(),
Hope that makes sense. Thanks!