-
6 Jan 2007 10:58 PM #11
Jack -Code:<script> var id = 3; function addProfile() { var tplNode = document.getElementById('profile-template'); var table = document.getElementById('profile-table'); var tpl = new YAHOO.ext.DomHelper.Template(tplNode.value); if (table.rows[0]) { tpl.insertBefore(table.rows[0], {profilename: 'My Profile', id: id}); } else { tpl.append('profile-table', {profilename: 'My Profile', id: id}); } id++; } </script> <input type="button" onClick="addProfile();" value="Add a Profile"> <table> <tbody id="profile-table"> </tbody> </table> <textarea style="display:none" id="profile-template"><tr id="profile{id}"><td>{profilename} {id}</td></tr></textarea>
I tried your advice as you can see here. This works in ff but not in IE, any ideas?
Aaron
-
7 Jan 2007 1:11 AM #12
Is there a reason why you're trying to get your template from body elements rather than simply defining it as a string?
Code:var tpl = new YAHOO.ext.DomHelper.Template('<tr id="profile{id}"><td>{profilename} {id}</td></tr>');
-
7 Jan 2007 8:32 AM #13
Brian -
The reason I am storing the template in HTML is so that I can get separation between my javascript and HTML in a very clean way. As an aside I've tried to store the template directly in the code and receive the same error as before in IE.
Aaron
-
7 Jan 2007 10:33 AM #14
Not to get into a philosophical debate
Originally Posted by aconran
but the template isn't really part of your HTML! Even though it looks like HTML, it is an HTML template that only exists because of, and is only used by, your javascript code. Thus, it is part of your javascript. I wouldn't fret too much about trying to keep it separate personally, especially if you have to resort to hacking it up anyway.
-
13 Mar 2007 11:48 AM #15
Invalid Pointer exception in IE using Template
Invalid Pointer exception in IE using Template
Is this a known bug that is fixed in the new release? Is there a known workaround I can use without going through the migration to the new code?
I get the same invalid pointer exception in IE that others have mentioned. The exception is being thrown from this method:
The tag is 'tr' and the where string is "afterend". The html string is (all one line):Code:var insertIntoTable = function(tag, where, el, html){ if(!tempTableEl){ tempTableEl = document.createElement('div'); } var node; if(tag == 'table' || tag == 'tbody'){ tempTableEl.innerHTML = '<table><tbody>'+html+'</tbody></table>'; node = tempTableEl.firstChild.firstChild.firstChild; }else{ tempTableEl.innerHTML = '<table><tbody><tr>'+html+'</tr></tbody></table>'; node = tempTableEl.firstChild.firstChild.firstChild.firstChild; } if(where == 'beforebegin'){ el.parentNode.insertBefore(node, el); return node; }else if(where == 'afterbegin'){ el.insertBefore(node, el.firstChild); return node; }else if(where == 'beforeend'){ el.appendChild(node); return node; }else if(where == 'afterend'){ el.parentNode.insertBefore(node, el.nextSibling); return node; } }
Control flows to the first 'else', but node gets set to null. I'm getting this calling myTemplate.insertAfter(headerRow, values, true). headerRow is the first row in the table. The table looks like this:Code:"<tr valign=\"top\" class=\"observation-list-row\" id=\"observationListRow12367828\"><td align=\"left\" rowspan=\"2\" class=\"noprint\"><input type=\"checkbox\" name=\"deleteID\" value=\"12367828\"/></td><td align=\"left\">Red Cat B</td><td align=\"left\">Red Cat B2</td><td align=\"left\"></td><td align=\"left\"><a href=\"/CRMApp/company/CompanyView.do?id=70585\">A & L Contractors, Inc.</a></td><td align=\"left\"><font color=\"green\">Nice</font></td><td align=\"left\"></td><td align=\"center\"></td><td align=\"left\" nowrap=\"true\"></td><td align=\"left\" class=\"noprint\"><a href=\"#\">Edit</a></td></tr>"
Code:<table border="0" cellpadding="1" cellspacing="1" class="listTable"> <tbody> <tr class="header" id="observationListHeader"> <td align="center" class="noprint"></td> <td align="center" class="columnHeader">Category</td> <td align="center" class="columnHeader">Sub-Category</td> <td align="center" class="columnHeader">Project Segment</td> <td align="center" class="columnHeader">Contractor</td> <td align="center" class="columnHeader"></td> <td align="center" class="columnHeader">Unsafe Conditions - Severity</td> <td align="center" class="columnHeader">Done?</td> <td align="center" class="columnHeader">Due / Completed</td> <td align="center" class="noprint"></td> </tr> </tbody> </table>
Similar Threads
-
Ext.DomHelper.Template: one template, ten YUI grids
By moraes in forum Community DiscussionReplies: 11Last Post: 18 Dec 2012, 4:55 AM -
Ext Template to insert DOM nodes rather than strings?
By SteveEisner in forum Ext 2.x: Help & DiscussionReplies: 0Last Post: 21 Mar 2007, 4:47 PM -
Ext.DomHelper.Template or Ext.Template?
By mystix in forum Ext 2.x: Help & DiscussionReplies: 4Last Post: 1 Mar 2007, 3:05 PM -
Help with DomHelper & Tables
By tony.summerville in forum Ext 1.x: Help & DiscussionReplies: 1Last Post: 12 Jan 2007, 5:58 AM -
0.33 beta 3 DomHelper fails to insert html with IE
By moedusa in forum Ext 1.x: Help & DiscussionReplies: 3Last Post: 8 Nov 2006, 4:58 AM


Reply With Quote