Daily Archives: February 26, 2012

JBTabBarController (Cocoa Controls)

Posted by Cocoa Controls at Cocoa Controls
JBTabBarController aims to be a drop-in replacement of UITabBarController, but with the intention of letting developers easily customise its appearance. JBTabBar uses images for all UI elements except for the labels on TabBar items. This gives the Developer/Designer the freedom to customise the all aspects of the TabBar.

In particular, the selected and unselected images for each TabBar item can be specified and are full colour images not clipping masks.

The included example attempts to emulate the standard UITabBar design provided by Apple. The layer styles used to create the TabBar images in Photoshop are in the Extras folder.

The project uses ARC and targets iOS 4.0+ devices.

image of this control

Pegasus (Cocoa Controls)

Posted by Cocoa Controls at Cocoa Controls
A lightweight Objective-C framework for Cocoa Touch to create UIKit view hierarchies in XML.

image of this control

jQuery Tip #4 – Use the on() Function for Event Handling (Dan Wahlin’s WebLog)

Posted by dwahlin at Dan Wahlin's WebLog

Previous Tips:

jQuery provides several different functions that can be used to handle events. Choices include shortcut functions such as click() and hover(), the live() function, the delegate() function, and the bind() function. The live() and delegate() functions can be used to handle event bubbling scenarios such as rows in a table being clicked, while the shortcut functions act as wrappers around the bind() function.

jQuery 1.7+ includes a new function named on() that wraps the previous event handler functions into one convenient API that can be used to handle everything from simple events to more complex event bubbling scenarios. An example of using on() to handle a simple click event is show next.


$('#myButton').on('click', function () {     alert('Clicked the Button'); }); 

You can always use the shortcut click() function as well. I generally prefer the shortcut functions when handling single events since I can eliminate quotes from the code but that’s just my personal preference.

When handling multiple events on() is quite useful. You can use its mapping functionality as shown next to map events to callback functions:


$('#MyTable tr').on({     mouseenter: function () {         $(this).toggleClass('over');         //perform other functionality needed during mouseenter     },     mouseleave: function () {         $(this).toggleClass('over');         //perform other functionality needed during mouseleave     } });

The on() function can also be used in place of live() or delegate() to detect when a child of a given parent container has been clicked. For example, when a table has a large number of rows that need event handlers to detect when a user clicks them or hovers over them, the on() function can be used. Rather than attaching an event handler to 1000 rows, on() can be used to attach a single event handler (or map event handlers) that handles row events to the containing table’s tbody element. An example of using on() for this purpose is shown next:


$('#customerTable tbody').on('click', 'tr', function() {     alert('Clicked a Row'); }); 

This code will cause click events triggered within a table to bubble up to the containing tbody element which handles them. It’s very efficient to handle events this way because only 1 event handler is added yet 1000s of potential row events can be handled. Future rows that are dynamically added to the table are also handled automatically. If you’re wondering what happened to jQuery’s delegate() function (which does the same type of thing), it can still be used. However, on() is now the preferred event function to use with jQuery 1.7+. To remove one or more events associated with a DOM node you can use the off() function.


Live Example

If you’re interested in learning more about jQuery or JavaScript check out my jQuery Fundamentals or Structuring JavaScript Code courses from Pluralsight. We also offer onsite/online training options as well at www.thewahlingroup.com.




jQuery provides many different options for handling events including shortcut functions, live(), delegate(), bind(), and on(). Although they all get the job done, if you’re using jQuery 1.7 or higher it’s recommended that you use the new on() function for your event handling needs.

EEToolbarCenterButton (Cocoa Controls)

Posted by Cocoa Controls at Cocoa Controls
EEToolbarCenterButton is a component to add a featured button to the center of UIToolbar. It handles button alignment, and helps you use buttom images whose height is larger than UIToolbar height.

image of this control

WP Like Button Plugin by Free WordPress Templates