Wysmedia.com

Icon

~ We make IT easy for you ~

Zebra Style on Table with JQuery

This is very cool tips that I found from jquery documentation. Create a table zebra with just one line of code.

You define a css for evenrow and oddrow with different colors.

$('#yourTableID tr:even').attr('class','evenrow');
$('#yourTableID tr:odd').attr('class','oddrow');

Firebug console

Just playing with Firebug and instead of displaying “annoying” alert, we can use console.log(”your object”);

for example

var a = $("#test").val();
console.log(a);
var b = $("inputA");
console.log(b);

easy ? :)

Nice ICal Calendar with JQuery

Stefanoverna.com write how to create a nice looking calendar like those in ICal using Jquery. It looks good :)

on
this web

Trapping Server Error

Sometimes we found that our server are not behave normal, like there are bugs or server produce runtime exception (or error 404 etc). Those exception are not returned by ajax. So it will keep hidden and seems nothing happened. But if you have firebug installed, you can found that there are errors happened from your server.

So here is how you can trap all errors and displayed on your screen (without using firebug).

This example works on grails main layout (but you can use this tips on any programming language, just put this code on main layout). My code using Jquery and JQalert to display the error

1
2
3
4
5
6
7
$(document).ready(function(){
                $(document).ajaxError(function(event, request, setting){
                    var re = /<br\/>|<br>/g; // for replacing all <br/> with empty string in error 404
                    var txt = request.responseText.replace(re,"");
                    jqalert(txt,"Server Error");
                });
});