Posts Tagged ‘javascript’
Checking all your checkboxes with jQuery
Ok I know this blog is geared towards ExtJS and I do expect you to lambast me for posting jQuery code snippets but, in my free time one lunch time I decided what it would be like to rewrite the ExtJS vertical checkbox examples I’ve been posting using jQuery.
Turns out, there’s not a great deal of difference in the length of the code, maybe the clarity and readability is slightly improved with jQuery, although looking at it there’s not a great deal in it. So for shits n giggles here’s my jQuery code:
<script type="text/javascript">
$(document).ready(function(){
$("#select_none").click(function(){
$(":checkbox").attr("checked", false);
$("#update_button").attr("disabled", true);
return false;
});
$("#select_all").click(function(){
$(":checkbox").attr("checked", true);
$("#update_button").attr("disabled", false);
return false;
});
// clear all checkboxes.
$("#select_none").click();
$(":checkbox").click(function(){
if($(this).attr("checked") == true)
{
if($("#update_button").attr("disabled")==true)
$("#update_button").attr("disabled", false);
}
else
{
if($(":checked").length == 0)
{
$("#update_button").attr("disabled", true);
}
}
})
});
FYI if you’re interested in checking out jQuery in more detail, have a look at the post over on Ajaxian filled with jQuery videos presented by John Resig himself.
Javascript video tutorials / lectures
Been on my summer holidays so no blogging for the last week, so whats new I bet you’re thinking – you never blog anyway.
No well, you’re right, but I have some great Javascript resources for you to watch! yes not read… watch… so sit back fire up your browser and let the information come to you.
Douglas Crockford Javascript Lectures part 1
Douglas Crockford Javascript Lectures part2
Douglas Crockford Javascript Lectures part 3
Douglas Crockford Javascript Lectures part 4
If you watch all of those, you could go on and read this:
JavaScript Tips for Novices, Acolytes, and Gurus and then explain it to me
Laters
Console logging and debugging with Firebug
Guy and Girls…
Firebug rocks. If you haven’t been using it already you shouldn’t really call yourself a JavaScript programmer, or a web developer for that matter.
Get Firebug installed and read the tutorial on logging and debugging. It makes your code a heck of a lot cleaner and removes the need for annoying alerts everywhere!
If you’re not using Firefox, firstly why not? and secondly here’s a list of web development tools for Internet Explorer. Go fill ya boots! However, a better solution exists for those who are Firebug enthusiasts but have crappybrowseritus, this is something I’ve not tried out but should work for IE, Opera and Safari browsers. Use Firebug Lite to debug javascript in IE, Safari and Opera – if you have tried this, please let me know how you got on.
Cheers
James