Note that there are some explanatory texts on larger screens.

plurals
  1. PO<td> tags are stripped from text when injected in MooTools Elements
    text
    copied!<p>I'm trying to build some JavaScript in MooTools that fetches table row markup from the server, then adds it to a table. I have an object named <code>htmlAjax</code> that's set as a MooTools <code>Ajax</code> object. The object gets the HTML from the server correctly (tested this in the Firebug console), but when I attempt to add this markup to a new element, the <code>&lt;td&gt;</code> elements get stripped out. Here is my function that captures the data from the HTTP request and attempts to add a row:</p> <pre><code>htmlAjax.addEvent('onComplete', function (data) { var slot = new Element('tr'); slot.setHTML(data); slot.injectInside($('volunteer_slots')); }); </code></pre> <p>The response I get back from the server in <code>data</code> looks like this:</p> <pre><code>&lt;td&gt;&lt;div class="title" rel="60"&gt; &lt;a class="modal" href="index.php?view=volunteerslot&amp;amp;tmpl=component&amp;amp;id=60" rel="{handler: 'iframe', size: {x: 650, y: 550}}" &gt;test&lt;/a&gt; &lt;/div&gt; &lt;/td&gt; &lt;td class="button_column"&gt; &lt;img src="images/publish_x.png" /&gt; &lt;/td&gt; &lt;td&gt;0 minutes&lt;/td&gt; &lt;td&gt;&lt;select name="volunteers[60]" id="volunteers60" class="inputbox"&gt;&lt;option value="0" selected="selected"&gt;(select...)&lt;/option&gt;&lt;option value="63" &gt;Joe LeBlanc&lt;/option&gt;&lt;option value="64" &gt;Test User&lt;/option&gt;&lt;option value="65" &gt;Test User&lt;/option&gt;&lt;option value="66" &gt;Test User&lt;/option&gt;&lt;option value="67" &gt;Test User&lt;/option&gt;&lt;/select&gt;&lt;/td&gt; &lt;td&gt;&lt;select name="total_time_spent[60][hours]" id="total_time_spent60hours" &gt;&lt;option value="0" selected="selected"&gt;0&lt;/option&gt;&lt;option value="1" &gt;1&lt;/option&gt;&lt;option value="2" &gt;2&lt;/option&gt;&lt;option value="3" &gt;3&lt;/option&gt;&lt;option value="4" &gt;4&lt;/option&gt;&lt;option value="5" &gt;5&lt;/option&gt;&lt;option value="6" &gt;6&lt;/option&gt;&lt;option value="7" &gt;7&lt;/option&gt;&lt;option value="8" &gt;8&lt;/option&gt;&lt;option value="9" &gt;9&lt;/option&gt;&lt;option value="10" &gt;10&lt;/option&gt;&lt;option value="11" &gt;11&lt;/option&gt;&lt;option value="12" &gt;12&lt;/option&gt;&lt;option value="13" &gt;13&lt;/option&gt;&lt;option value="14" &gt;14&lt;/option&gt;&lt;option value="15" &gt;15&lt;/option&gt;&lt;option value="16" &gt;16&lt;/option&gt;&lt;option value="17" &gt;17&lt;/option&gt;&lt;option value="18" &gt;18&lt;/option&gt;&lt;option value="19" &gt;19&lt;/option&gt;&lt;option value="20" &gt;20&lt;/option&gt;&lt;option value="21" &gt;21&lt;/option&gt;&lt;option value="22" &gt;22&lt;/option&gt;&lt;option value="23" &gt;23&lt;/option&gt;&lt;option value="24" &gt;24&lt;/option&gt;&lt;/select&gt;&amp;nbsp;hours&amp;nbsp;&amp;nbsp;&lt;select name="total_time_spent[60][minutes]" id="total_time_spent60minutes" &gt;&lt;option value="0" selected="selected"&gt;0&lt;/option&gt;&lt;option value="15" &gt;15&lt;/option&gt;&lt;option value="30" &gt;30&lt;/option&gt;&lt;option value="45" &gt;45&lt;/option&gt;&lt;/select&gt;&amp;nbsp;minutes&lt;/td&gt; &lt;td class="button_column"&gt; &lt;img src="images/tick.png" /&gt; &lt;/td&gt; </code></pre> <p>Once I call <code>setHTML</code> on the <code>slot</code> variable (passing in <code>data</code>), the <code>&lt;tbody&gt;</code> element <code>volunteer_slots</code> has a new row, but that new row contains everything except for the <code>&lt;td&gt;</code> elements. Is there any way to prevent this from happening?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload