Category Archives: Code Libraries

JQuery Move Table Rows Up And Down

To simply and easily move table rows up and down with in the table, use jquery.

With a table like:

<table>
<tbody>
<tr class="MoveableRow">
<td>Data 1</td>
<td><span class="down_button">down</span><span class="up_button">up</span></td>
</tr>
<tr></tr>
<tr class="MoveableRow">
<td>Data 2</td>
<td><span class="down_button">down</span><span class="up_button">up</span></td>
</tr>
<tr></tr>
</tbody>
</table>

You can then have some javascript like:


            $('.down_button').live('click', function () {
                var rowToMove = $(this).parents('tr.MoveableRow:first');
                var next = rowToMove.next('tr.MoveableRow')
                if (next.length == 1) { next.after(rowToMove); }
            });

            $('.up_button').live('click', function () {
                var rowToMove = $(this).parents('tr.MoveableRow:first');
                var prev = rowToMove.prev('tr.MoveableRow')
                if (prev.length == 1) { prev.before(rowToMove); }
            });

Previously I found a post somewhere that used the replaceWith method of jQuery. This wouldn’t retain newly written text in input boxes I had there. after and before work like charms, because you can pass in a jquery object as the content. Pretty slick.


Game Dev Focus

It’s been a very long time since I said I wanted to develop a game.  And I have been very busy since then.  Work, home, etc.  But I have been tinkering in the meantime.  I have experimented with Python using PyGame and Panda3D.  The trick to that is I don’t know Python (yet).  I have played around with java using  LWJGL, Slick, and a little bit of  jME.  I’ve even just did some accelrated graphics using Java2D thanks to the great tutorials on Coke And Code.

I am going to make a game; game development is fast becoming my software engineering passion.  I have decided to start with a simple Tic Tac Toe game using Java2D and accelerated graphics, which I have already begun to develop in the spare time I can spare.  If you are reading and are interested, keep coming back and see the results.

Thanks again for everyone in the world who creates game libraries, tutorials, etc.


jQuery Is My New Best Friend

I have been struggling for weeks upon weeks upon mind bending, agonizing weeks to solve what I would think to be a simple javascript problem. I needed a popup box to come up just left and center of another element. Well I searched through results provided by Google and Yahoo! and found a number of solutions that didn’t work for my particular situation. However, those examples provided a stepping stone for me to figure out how to position it where I wanted. The next problem was re-positioning the popup if it went beyond the top or bottom edge of the window viewport. This is where jQuery came to the rescue. If I had discovered this earlier, a lot of headache would have been prevented and I would have more hair.

jQuery has this: $(“#popup”).offset(), which returns the elements absolute top and left positions no matter where they are in the page and no matter how many elements they are nested in.

Thanks to smart people.


Many JavaScript Libraries

So I found I new JavaScript library. Maybe you’ve heard of it. EXT JS. I have been using PrototypeJs and the Script.aculo.us library for a little while, but just now came across this new library. I have only briefly looked at EXT JS, namely their desktop,which , though slow and a little bug prone, looks very good. The things we can do with the web are limitless and the more we stretch ourselves by attempting new things the better.

So I think everyone knows that there is a plethora of tools at the disposale of the web developer. How then do we decide which are the right tools for us? I think I will explore the different tools I have come across, write about them, and let whomever decides to read comment. So stay tuned.


Follow

Get every new post delivered to your Inbox.

Join 59 other followers