yesterday david shuck posted some jquery code he was using to toggle the display of some form information. one of the things i noticed about his code was that he was using jquery to bind to the change event of a radio button, but the code to acutally toggle the display was contained in a separate function.

i commented him back about how he could combine these two functions into one jquery chain thus making the code a little more readable. today i want to share this with you, let’s take a look at the two functions:

$("#RequireCCInfo").change(function(){
    toggleCreditCardCompanyPanel();
}); 	

function toggleCreditCardCompanyPanel()	{
    if ($("#RequireCCInfo").attr("checked") == true)
    $("#CreditCardCompanyPanel").show();
    else $("#CreditCardCompanyPanel").hide();
}

toggleCreditCardCompanyPanel();

basically the first function bind to the change event of a checkbox with an id of RequireCCInfo and then calls the toggleCreditCardCompanyPanel to toggle the display of the panel.

so how could chaining in jquery help us clean this up a little? remember that with jquery you can bind a function to an event and also trigger event. with this knowledge you can do things like:

$(function(){
$(”#RequireCCInfo”).bind(”change”, function(){
// your code
}).change();
});

as you can see from the code above, we’re binding some code to the change event and then immediately after triggering it, this is the same thing a creating a separate function and then calling it. armed with this knowledge we can now perform the clean up:

$(function(){
$(”#RequireCCInfo”).bind(”change”, function(){
$(”#RequireCCInfo:checked”) ? $(”#CreditCardCompanyPanel”).show() : (”#CreditCardCompanyPanel”).hide();
}).change();
});

BASH was really slow there for awhile so I had to let it catch up. Stupid me, it kinda overlapped me so this week is a HUGE BASH posting. Also There is a little something at the end of the list (don’t peek).

Generous Plug: My brother started a blog called My Junk Mail. Basically it’s a collection of all the jokes and funny shit he gets sent to him on a daily basis. Trust me on this, he gets some good stuff. You would never think that people in the mortgage industry on that fucked up…. and to think these pricks are the ones that get us money O_o

http://www.bash.org/?830741
http://www.bash.org/?830747
http://www.bash.org/?830989
http://www.bash.org/?831195
http://www.bash.org/?831285
http://www.bash.org/?831311
http://www.bash.org/?831674
http://www.bash.org/?832266
http://www.bash.org/?832291
http://www.bash.org/?832919
http://www.bash.org/?832984
http://www.bash.org/?833499
http://www.bash.org/?834654
http://www.bash.org/?835030
http://www.bash.org/?835536
http://www.bash.org/?835939
http://www.bash.org/?837574
http://www.bash.org/?839482
http://www.bash.org/?839563
http://www.bash.org/?839694
http://www.bash.org/?839727
http://www.bash.org/?841280
http://www.bash.org/?842161

(your peeking… aren’t you, you fuck!)

I’m starting something new. Every week (hopefully) I’ll be picking out the top two bashes for the week and posting them at the end of the list. These are the ones I think are the best, and on that note, I want people to start leaving comments telling me what their favorite for the week is. During the slow times on bash.org, I can look back and pick out some good ones for my Classic BASH posts.

Don’t let another Friday go by without BASH!!!!!

http://www.bash.org/?833485
http://www.bash.org/?835023

And now for something new:

A bug was introduced in 2.0.1 that has been fixed. If you downloaded 2.0.1, please download the new version from the box.net widget with the date of 02/20/2008.

This will be the last release with version numbers. From now on all future release with just be name according to the release date ex: popupwindow20080220.zip

Quick little thing. I’ve updated PopupWindow to now support the location and menubar attribute as suggested by Matthew. You can download the latest from the box.net sidebar.

Remember to comment here with your suggestions. Thanks

It’s been awhile but now PopupWindow version 2.0 has been released. Here is what changed:

cleaned up the index.html example page.
added the ability to have the popups open in the same window. request by Cameron
fixed a major bug where the settings variables wasn’t vared.

Go get it from the box.net widget  —>

Today marks the second birthday for jQuery (my favorite javascript library)! To celebrate, version 1.2.2 has been release. Go check it out!

Damn I feel good and shocked right now. Who would have thought that a jQuery plugin I wrote on a whirlwind would get this much attention. I think I literally wrote the first draft within 5 minutes. At the time I was working at revamping a website that used a lot of popupwindows and needed a way to manage the different sizes of the windows. Our the next couple of days I kept adding to it and decided to release it to the public. It’s grown over time to what it is today.

What I would like to know how is who’s using it? Click here to go to the “homepage” for the plugin and leave a comment with a link to your website. Tell me in the comment what your think about it. If anything it will give you a little traffic since the page is getting between 150 -200 visits a day.

I feel honored.

November 1, 2007

Andrea over at andreacfm, has started what I consider to be one of the coolest projects: creating custom tags out of jQuery plugins. Personally I really haven’t been a fan of the new ColdFusion tags because of the amount of javascript that is loaded when you want to use them. By using jQuery, this really isn’t a issue. Plus it’s jQuery for God’s sake!

So why do I feel so honored? Well there is actually a custom tag that was created out of my PopWindow Plugin!

jQuery 1.2 released!!!

September 11, 2007

Big news out of the jQuery camp. 1.2 is now officially released. Check out the release notes. Remember that this release removed a lot of methods from 1.4 so be sure to read the upgrade documentation on how to upgrade.

On a side note: I couldn’t put my feeling about this release into better word then this.

Excellent presentation from John about writing and maintaining your own javascript library.

Added bonus at 58:46