Note that there are some explanatory texts on larger screens.

plurals
  1. POA simple re-ordering of DIV's inside parent element using jQuery appendTo method
    primarykey
    data
    text
    <p>Making my first post here to get feedback on a particular solution to a problem that I dealt with yesterday. I came up with something that solves my problem and achieves the effect desired but I think that at best it's an inelegant solution and at worst an ugly hack.</p> <p>The problem: How can I re-order four div's on a page that are hard-coded in a specific order on the page. The goal: a method of quickly re-ordering these blocks based on client preference.</p> <p>The constraints: I can't touch the markup except to add a classes and ids or wrappers (I can't re-structure the html at all). This is for an existing, working, product that is already in use by several different clients.</p> <p>Here is the markup with content removed: </p> <pre><code>&lt;!-- content-panel 2 --&gt; &lt;div id="home-messages-box" class="content-panel"&gt; &lt;table cellspacing="0"&gt; &lt;tr&gt; &lt;td class="tableCaption"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;table class="tableContent" cellpadding="0" cellspacing="0"&gt; &lt;tr&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/div&gt; &lt;!-- content-panel 3 --&gt; &lt;div id="home-programs-box" class="content-panel"&gt; &lt;table cellspacing="0"&gt; &lt;tr&gt; &lt;/tr&gt; &lt;/table&gt; &lt;table class="tableContent" cellpadding="3" cellspacing="3"&gt; &lt;tr&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/div&gt; &lt;!-- content-panel 4 --&gt; &lt;div id="home-actionitems-box" class="content-panel"&gt; &lt;table cellspacing="0"&gt; &lt;tr&gt; &lt;td class="tableCaption"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;table class="tableContent" cellpadding="0" cellspacing="0"&gt; &lt;tr&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/div&gt; &lt;/div&gt;&lt;!-- content-panel-wrapper --&gt; </code></pre> <p>And here is the jQuery I'm using to re-order those Divs after the page loads: </p> <pre><code>$(function () { $("#home-actionitems-box").appendTo("#content-panel-wrapper"); $("#home-welcome-box").appendTo("#content-panel-wrapper"); $("#home-messages-box").appendTo("#content-panel-wrapper"); $("#home-programs-box").appendTo("#content-panel-wrapper"); }); </code></pre> <p>Is there an easier, more elegant way to do this? I accept that it is probably a hacky solution to an inflexible structure that is the result of no UI/UX design thinking at the beginning of the project (years ago). But I am interested in the opinion of other people who sometimes have to come up with inelegant solutions to problems like this.</p>
    singulars
    1. This table or related slice is empty.
    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.
    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