I'm currently using the Mootools Element constructor method to dynamically add a new row into a table.
function newPermission(somedata) {
var newUserPerm = new Element('tr', {
'html': '<td>foo</td><td>bar</td>'
});
newUserPerm.inject('permissions_table');
}
However, upon checking the resulting code, the following HTML string gets added to the table:
<tr>foobar</tr>
I'm sure there's some way to send the HTML tags as well, bu开发者_运维百科t I can't find much on it here, except one other question, in which the user had an outdated ver. of Mootools...
this has been fixed in mootools 1.3 beta and i think only affects tables (otherwise html setters via element constructors are fine) - in the mean while, do not set the html through the element constructor but set the it after you create the TR:
var tr = new Element('tr').inject(document.id("foo").getElement("tbody"), "top");
tr.set("html", '<td>foo</td><td>bar</td>');
here it is working as you had it in 1.3: http://www.jsfiddle.net/dimitar/ALsBK/
and here it is breaking in 1.2.4: http://www.jsfiddle.net/dimitar/ALsBK/1/
and working in 1.2.4: http://www.jsfiddle.net/dimitar/ALsBK/2/
精彩评论