Post by coolcoolcool on May 11, 2012 14:20:36 GMT -8
Anyone here experiment with it?
I started work for a small-ish company that specializes in phone solutions and I've been programming an area of their package with php/html/javascript. I can't really talk too much about the company for privacy reasons, but I noticed they were using JQuery and I always wondered how user friendly it was. I started using it a few days ago and it blew me away.
Today, I had to create a script for a table that had links on the top of each column that would sort the table. I was shocked at how little code it needed. After I set up each cell element to be of a specific class, this was all I needed:
where sortingArea is a table with that id.
and an example of setting a link with id phoneSort to sort the table on click is
Where phoneColumn is the className of the cells I want to reorder. The e.preventDefault prevents the link from switching pages onclick.
Plus, I looked into it and it has very versatile support for JSON/AJAX, there's built in animation functions, it makes event handling almost trivial, and there's many, many, many useful additions for it on the internet.
Anyway, this is obviously nothing new. I had just never played with it before and I'm loving it. It almost makes me want to design a proboards forum just to experiment with it.
I started work for a small-ish company that specializes in phone solutions and I've been programming an area of their package with php/html/javascript. I can't really talk too much about the company for privacy reasons, but I noticed they were using JQuery and I always wondered how user friendly it was. I started using it a few days ago and it blew me away.
Today, I had to create a script for a table that had links on the top of each column that would sort the table. I was shocked at how little code it needed. After I set up each cell element to be of a specific class, this was all I needed:
var tableSort = function(className)
{
$("#sortingArea").html($("#sortingArea tr").sort(function(a,b){return ($(a).children().next("." + className).html() > $(b).children().next("." + className).html()) ? -1 : 1;}));
};
where sortingArea is a table with that id.
and an example of setting a link with id phoneSort to sort the table on click is
$(document).ready(function(){
$("#phoneSort").click(function(e){ tableSort("phoneColumn"); e.preventDefault(); });
});
Where phoneColumn is the className of the cells I want to reorder. The e.preventDefault prevents the link from switching pages onclick.
Plus, I looked into it and it has very versatile support for JSON/AJAX, there's built in animation functions, it makes event handling almost trivial, and there's many, many, many useful additions for it on the internet.
Anyway, this is obviously nothing new. I had just never played with it before and I'm loving it. It almost makes me want to design a proboards forum just to experiment with it.