Jun. 18th, 2009

jQuery

Jun. 18th, 2009 12:18 pm
netbard: (Default)
So I've been working with jQuery for the past few weeks - this is an open-source javascript library that was included with the Telerik controls we purchased. It is also, I believe, included with Visual Studio, or will be in a future release. Let me tell you, it makes things a lot easier. One example - moving table rows up or down in the table. This is actually quite difficult to do in Firefox (IE provides a non-standard method to do it for you) - the only way to do it that I've found is to clone the affected table row, remove the old one from the table and add the new one. I hate cloning objects. I'm not going to include the code on how to do this, because I didn't write it. But here's a link - http://www.w3hobbyist.com/web-designing/moving-table-rows-up-and-down-with-javascript/

Once I figured out that this was going to be hard to do, I thought I would try to do it in jQuery. I hit the documentation site for jQuery (http://docs.jquery.com/) and found the answer really quickly. In the examples below, pretend that tableRow is the row of the table that needs to be moved.

Moving an item down in the table:
$(targetRow).insertAfter($(targetRow).next())

 
Moving an item up in the table:
if (targetRow.rowIndex > 1) {
     $(targetRow).insertBefore($(targetRow).prev());
}
 
That is,actually, pretty amazing.
netbard: (Default)
One of my favorite scenes from any anime. Massively spoilery regarding Gundam Seed.
Spoilers behind the cut... )

Profile

netbard: (Default)
netbard

September 2025

S M T W T F S
 123456
78910111213
14151617181920
2122232425 26 27
28 29 30    

Most Popular Tags

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated Oct. 2nd, 2025 07:31 am
Powered by Dreamwidth Studios