Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery: Replacing custom HTML tags with valid HTML code
    primarykey
    data
    text
    <p>I'm currently working on an AJAX site where we use custom HTML tags to create template pages.</p> <p>This is the HTML part:</p> <pre><code>&lt;div id="main"&gt; &lt;div&gt; &lt;ns:zone name="navigation" /&gt; &lt;/div&gt; &lt;div&gt; &lt;ns:zone name="page" /&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>The above example works just fine, with the following substitution done by JQuery:</p> <pre><code>$("ns\\:zone").each(function() { $(this).replaceWith(getHtml($(this).attr("name"))); } ); </code></pre> <p>However, you may have noticed the HTML code could look much better like this:</p> <pre><code>&lt;div id="main"&gt; &lt;ns:zone name="navigation" /&gt; &lt;ns:zone name="page" /&gt; &lt;/div&gt; </code></pre> <p>Unfortunately, in that case, the first "zone" tag will be correctly replaced, but the second "zone" tag will disappear. I don't think it's due to the browser (I've tested it in Chrome and Firefox) but rather to JQuery. Could it be due to JQuery "rebuilding" the DOM tree, and deleting my "invalid" HTML tags?</p> <p>I've also tried with JQuery's html() method instead of replaceWith(). The results are the same.</p> <p>Do you see where the problem lies? It seems like JQuery <em>does</em> support custom HTML, but maybe not correctly? Should I setup my own xmlns?</p> <p>As a side note: The website should allow the customer to very easily create a custom template, or to convert a bought website into a template for our application. We are currently developing the web services in PHP, but we may partially move a part of the application to a glassfish server. Therefore, this mechanism should <em>not</em> rely on the server technology! Quite obviously, the website should be as cross-browser as possible.</p> <p>--</p> <p>Thank you very much for any suggestion.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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