ColdFusion 8 Ajax UI Controls: Refresh active tab???????

Where are you?

I’ve tried numerous things to get the tab to refresh. First off I was looking at Ext 2.0 docs but I didn’t realize it until I did a dump on the _ColdFusion.Layout.getTabLayout(“tabs”).getActiveTab()_ and noticed a method not mentioned on the docs. Oops…my bad! πŸ˜‰

So…instead of just bashing CF8’s attempt at UI Controls via Ajax I figured I’d ask anyone listening.

bq. How do you refresh the active tab dynamically?

Before you answer, let me clarify. I have N number of tabs and inside this particular tab I open a _CFWindow_ (a few gripes about this too) which does some updating and when done I need the selected tab to refresh the contents so it properly shows the latest and greatest info.

Here is what I found to work (and all that worked):

bq. function refreshActiveTab(){
var activeID = ColdFusion.Layout.getTabLayout(“tabs”).getActiveTab().id;
ColdFusion.Layout.hideTab(“tabs”, activeID);
ColdFusion.Layout.showTab(“tabs”, activeID);
ColdFusion.Layout.selectTab(“tabs”, activeID);
return;
}

That’s quite a sucky way to do it, IMO. The user doesn’t see the hide/show…at least in FF. In IE7 the modal background has no alpha (which looks crappy) so I can’t see it anyway.

Either way, after my trials tonight it merely validates my thoughts on CF’s Ajax UI Controls: they need a lot of work! I’ll rant later but the CF Ajax binding is SWEET (lacking a couple things but still sweet). I just want to see the UI controls come up to a really professional level.
</partialRant>

Javascript: Trim sentence to N number of words

I didn’t spend time looking through any of the JS utilities to do this so if there is one publicly available I’d suggest using it since I just coded this and haven’t run it through be 2 screen refreshes. πŸ™‚

bq. function trimByWord(sentence) {
var result = sentence;
var resultArray = result.split(” “);
if(resultArray.length > 10){
resultArray = resultArray.slice(0, 10);
result = resultArray.join(” “) + “…”;
}
return result;
}

I guess we can step through the code.

#) Set _result_ to the _sentence_ value passed in so if there aren’t more than 10 words it will just return the same string.
#) Split _result_ by spaces so a sentence like “I love to blog but sometimes get to busy. I’ll try harder.” will result in an array of 12 strings.
#) If _resultArray_ has more than 10 (put whatever number you want here) words, go to the next step. If not, skip to the last step.
#) Slice the array to only grab the first 10 (again, whatever number you want here) elements (the words) in the array.
#) _join()_ the array with a space so the _resultArray_ elements are now a string and add the ellipsis to the end.
#) Return the _result_.

That’s it. There are a few upgrades I’m going to make in a few minutes. Basically make sure the last character isn’t a period (if so, ignore the “…”) and maybe a couple others.

Hope this helps.

Integrating Spry with Lightbox

“Spry”:http://labs.adobe.com/technologies/spry/home.html is a great Ajax library and is pretty easy to use but seeing as you do not have the images in the html at the time of rendering in the browser “Lightbox”:http://www.huddletogether.com/projects/lightbox2/ doesn’t have access to the current _a_ and _area_ tags in the page. So…what’s the solution?

Well, there are other ways you can make this happen but here is one:

bq. Spry.Utils.addLoadListener(function() { setTimeout(function() { myLightbox.updateImageList(); }, 1000); });

Basically add a listener so when the data is loaded simply tell _myLightbox_ to update the image list (which is the function that parses the DOM) after 1 second (1000 milliseconds), just to give Spry enough time to render the html. _myLightbox_ is the instance name Lightbox.js creates for the Lightbox instance.

Feel free to explore other ways for adding listeners/observers to Spry and post them. I didn’t find much in Google so I figured I’d post my quick fix.

Spry Logo / Site

I’ve used “Adobe Spry”:http://labs.adobe.com/technologies/spry/ a few times and I think it is the easiest Ajax library to use. Well, I finally caught up on my RSS reading and the “Adobe Labs Latest Releases feed”:http://weblogs.macromedia.com/labs/index.xml showed a new Spry update. So, I went to the site to check it out and oooooooohhhhhh ahhhhhhhhh. πŸ™‚ It isn’t just amazing but it does look MUCH better.

**Logo**

Spry Logo

**New Site Design**

SprySite.JPG

Aptana IDE+Adobe AIR is SWEET!

Ok, this is my first impression and, as with all things, I’m sure I’ll find something wrong with it but right now…NOPE…IT ROCKS!

You can build “HTML+Javascript AIR applications”:http://labs.adobe.com/technologies/air/develop_ajax.html! I love it, again…at first glance. The more I play with it I’ll expand my thoughts but at this point this is about all I can say. lol. πŸ™‚

Oh, it is also useful for normal Javascript, Apple iPhone development, and more. Last note…it is free! πŸ˜€

Google AdSense: Nice Zip Code Help Popup

Yes, I’m trying to make a lil’ money off this blog (golf can get expensive; lol) so I went to setup AdSense and noticed something simple but sweet.

I clicked on the zip code textfield and voila…I get that popup. I thought it was general but then I noticed it actually showed potential/legit information about Arizona. πŸ™‚

Bravo Google…nice feature.