Column toggle popup not showing correctly the first time
Hi, I'm working in a jquery mobile site, where I have an ajax method that creates a table dinamically and then I use html() to add it to a div, a button renders the table each time, from 10 to 10 records, the very first time that the table is generated, the column toggle popup looks weird, right after I access #page1 but the following times, it shows correctly, when using the button, this is pretty much the code:
- function populateGrid()
- {
- var data1 = "<table data-role='table' data-mode='columntoggle' class='ui-responsive table-stroke' id='table1' data-column-btn-theme='b'>";
- data1 += "<thead>";
- data1 += "<tr>";
- data1 += "<th data-priority='1'>header1</th>";
- data1 += "<th data-priority='1'>header2</th>";
- data1 += "<th data-priority='2'>header3</th>";
- data1 += "</tr>";
- data1 += "</thead>";
- data1 += "<tbody id='myBody'>";
-
- $.ajax({
- type: "POST",
- contentType: "application/json",
- url: "http://url/service.svc/method1",
- data: JSON.stringify({ clientType: 'IS', from: fromValue, to: toValue}),
- dataType: "json",
- success: function (data){
- $($.parseJSON(data.d)).each(function(index, element) {
-
- data1 += "<tr><td><a href='#' class='linkTest'>" + element.field1 + "</a></td><td>" + element.field2 + "</td><td>" + element.field3 + "</td></tr>";
- });
-
- data1 += "</tbody>";
- data1 += "</table>";
-
- $("#table1-popup").remove();
- $("#tableDiv").html(data1).enhanceWithin();
- },
- error: function(result){
- alert(result.status + ' ' + result.StatusText);
- }
- });
- }
This works ok, but the result the first time is:
I would appreciate your help, thanks!