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.
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.
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.
Here is the markup with content removed:
<!-- content-panel 2 -->
<div id="home-messages-box" class="content-panel">
<table cellspacing="0">
<tr>
<td class="tableCaption">
</td>
</tr>
</table>
<table class="tableContent" cellpadding="0" cellspacing="0">
<tr>
<td>
</td>
</tr>
</table>
</div>
<!-- content-panel 3 -->
<div id="home-programs-box" class="content-panel">
<table cellspacing="0">
<tr>
</tr>
</table>
<table class="tableContent" cellpadding="3" cellspacing="3">
<tr>
<td>
</td>
</tr>
</table>
</div>
<!-- content-panel 4 -->
<div id="home-actionitems-box" class="content-panel">
<table cellspacing="0">
<tr>
<td class="tableCaption">
</td>
</tr>
</table>
<table class="tableContent" cellpadding="0" cellspacing="0">
<tr>
<td>
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table>
</div>
</div><!-- content-panel-wrapper -->
And here is the jQuery I'm using to re-order those Divs after the page loads:
$(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");
});
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.