Welcome Guest, Not a member yet? Register   Sign In
Xajax, <table>, firefox and IE
#1

[eluser]Unknown[/eluser]
Good morning to all.
I have an issue of compatibility between Firefox and IE.
I have a table layout which is predefined but its content is not.
On a button click, an xajax call is made to generate the table content.
The following code works great in Firefox but nothing in IE.
Following the code is the modification i tried with no sucess.

Table layout in view
Code:
&lt;?php
  foreach ($Slist as $s){

  
  echo "<table id=\"tblSup".$s['Sup_Id']."EmpList\" class=\"hidden\">";
  echo "<tbody>";
  echo "test in view";

  echo "</tbody>";
  echo "</table>";

?&gt;
$s['Sup_Id'] is passed from the controller as $data and this part works fine.

Ajax function in controller
Code:
function __GenEmpTable($sup){

   $objResponse = new xajaxResponse();
    $this->load->database('....');
    $tbl ="<tr><th colspan=\"2\">List Employes</th></tr>";
            $query = $this->db->query("Select LName,FName from SupToEmp where Sup_ID = '".$sup."'");
            $x=0;
            foreach($query->result_array() as $emp){
              $tbl = $tbl. "<tr> <td width=\"80%\">&lt;input type=\"text\" readonly=\"true\" value=\"".$emp['FName']."\" id=\"fname".$sup."_".$x."\"/&gt;&lt;input type=\"text\" readonly=\"true\" value=\"".$emp['LName']."\" id=\"lname".$sup."_".$x."\"/&gt;</td>";
              $tbl = $tbl. "  <td>&lt;input type=\"checkbox\" size=\"3\" id=\"chkbx".$sup."_".$x."\"/&gt;</td></tr>";
              $x++;
              }

   $tblid ="tblSup".$sup."EmpList";
   $objResponse->Assign($tblid,"value", $tbl);
//    $objResponse->Assign("tstajaxId","innerHTML",$tblid);
    return $objResponse;
  }


This code works A1 in firefox but nothing in IE

i tried commenting all $tbl line and changing the Objresponse $tbl for some text like: "Listing"
still the same.
the commented $objResponse is a div for testing ajax, this one worked fine in both FF and IE.

It seems that IE does not process innerHTML into a table.

Hope someone knows more than me on this and can help me get this working.
Thanks.
#2

[eluser]TheFuzzy0ne[/eluser]
You have no table rows or cells, thus the markup is invalid. By that, I mean the echo statement you have. It might be mucking up your output.

Try using the validator to validate your markup. Smile
#3

[eluser]TheFuzzy0ne[/eluser]
I would recommend using an empty <div /> as an attachment point for your table, and then dynamically inserting your table into that. There's a good chance that IE is seeing a table and body with no rows or cells, and therefore removing it, or changing it somehow.

JavaScript should only be used on a valid DOM. If the DOM is invalid, there's no guarantee that it will work as you might expect.

EDIT: I've just managed to validate an empty table with no problems, so I apologise for giving you incorrect information. However, as far as IE is concerned, it seems to have it's own opinion on what's valid and what's not, so I would still suggest you try hooking it onto a div.
#4

[eluser]Seppo[/eluser]
You are inserting the rows in the table, not in the tbody... IE has some issues (many issues, but in particular) with the JS generated tables - It requires a tbody.
#5

[eluser]TheFuzzy0ne[/eluser]
Well spotted. Grrr @ IE
#6

[eluser]Unknown[/eluser]
!!!SOLVED!!!!
I get amazed every time of how quick i get help, this is awsome.
Thank to all, by putting only the div in the view and generating the whole table in the ajax function worked perfectly.
I am still new to ajax therefor i would like to thank you for the validator and DOM information ill look into those.




Theme © iAndrew 2016 - Forum software by © MyBB