Learn more about user experience, web development and digital marketingView training courses

Our thinking

My colleague Paul and I have been discussing a feature of the jQuery library that really helps when adding events to a web page.

Historically using the click event or binding events to dynamic content could be tricky. This is because it’s possible to bind more than one event to an element. Care needs to be taken otherwise another event might be added to existing elements on the page.

The live event handler is an alternate method to bind or click, for example:

$("li").live("click",function(){
// code here
});

This means all current and future list items will now have this event handler bound to them. This is great because there’s no longer the need to manage bound events to new content.

Which got us arguing, what does ‘live’ stand for? Is it:

‘live’ – meaning it handles event binding on the fly as new elements are added, rather than having to call a function that binds events to the new items after finishing (think how a football match can be aired live – it’s happening in real time)

Steven

Or:

‘live’ – is an event that lives on regardless of whether content is generated or existing.

Paul

Let us know before this gets ugly! – just leave a comment below saying which of us you think is right – or even giving us your own take on it!

Here’s something I picked up by experimentation during the development of a CRUD system, which managed users, inventory, orders and reservations. The question was, how do I have page specific forms to add, update, and delete entries?

The answer was the accordion.

The problem with using the accordion in this way from a usability perspective is it won’t save the tab you were on if you post a form (e.g. if you have an update form in tab 2, where you select an ID from a drop-down box and submit to populate the form fields with the information in the row selected).

“Remembering” the state can be achieved with a PHP statement:

if (!$_POST['update_select
'] && !$_POST['delete_select']) {
?>
<script type='text/javascript
'>
$(function() {
$(
'#name_of_accordion').accordion({ collapsible: true, active: false });
});
</script>

This code says if an update or delete id select form hasn’t been posted, initialise the accordion without any tabs active. (active: false).

Right underneath that, add the next conditional statement:

}
if ($_POST[
'update_select']) {
?>
<script type=
'text/javascript'>
$(function() {
$(
'#name_of_accordion').accordion({ collapsible: true, active: 1 })
});
</script>

This statement adds a new property, active: 1. This tells the accordion that this tab should be open when the page loads (note: if you’re wondering why it’s 1 instead of 2, it’s because arrays always start at 0).

The last part of the statement handles the delete selector:

}
elseif ($_POST[
'delete_select']) {
?>
<script type=
'text/javascript'>
$(function() {
$(
'#name_of_accordion').accordion({ collapsible: true, active: 2 });
});
</script>

This statement does exactly the same as the update_select section, but corresponds to the delete selector. Now simply close off the elseif statement and you’re ready to roll:

}
?>

I hope this tip helps you as much as it helped me!

Photo credit: Crevier via Flickr/Creative Commons

In an age where user feedback has become so popular, accessible forms have become that much more important – find out exactly how to keep your forms as accessible as possible.

This is my first blog post for Webcredible – I’ve just recently joined the team here. My name is Steven Datt; I’ve recently completed a degree at Roehampton in Web & Multimedia computing, and I’m a web developer to the core. I can’t say just how excited I am to have landed this job, not many can say they got their ideal web development job straight out of uni!

I’m mainly a PHP sort of guy, though here at Webcredible I get to learn all sorts of things, from the frontend HTML & CSS to the back end scripting and databases, even the usability testing that goes on. Because of this, I’m in a good position to filter out, interpret and pass on whatever I learn to you, as I learn it – and I’m finding there’s a lot they can teach me here!

Increasing the clickable area for links may seem like a small and insignificant addition, but it actually greatly increases the usability your site offers, which in turn increases potential conversions.

You can see examples of this feature on our site and there’s a way of accomplishing it with a few lines of CSS.

To begin, we’ll create the list items for the navigation:


<ul>
<li><a href='#'>Link 1</a></li>
<li><a href=
'#'>Link 2</a></li>
<li><a href=
'#'>Link 3</a></li>
<li><a href=
'#'>Link 4</a></li>
</ul>

Simple List

Now to add a bit of style to it all:


ul {
list-style: none;
padding: 5px;
margin: 0;
}
ul li {
float: left;
margin: 0 5px;
}
ul li a {
color: #000;
text-decoration: none;
}
ul li a:hover {
background: red;
text-decoration: underline;
}

Which gives us this horizontal aligned navigation bar. Half way there!

icl-step2

So, we’ve created the links, and styled them, the last piece of the puzzle is to put in the CSS to maximise the link area:

ul li a {
color: #000;
text-decoration: none;
}

Add this code which will increase the “hit” area to encompass more space surrounding the link text:

display: block;
padding: 10px;

And we’re done! Told you it was simple!

icl-step3

Whilst recently updating our advanced CSS training course to include some CSS3 commentary, I became inspired by the amount of CSS3 that’s already out there. Browsers such as Firefox and Safari have really started embracing CSS3, which means that there’s a significant audience that you could be demonstrating your CSS3 skills to.

I have put together Top 10 CSS3 commands, some of which are fairly widely known and also some that personally I find interesting (Box-sizing – Old school box model).

Please let me know what you think and also any sites that you’ve seen using CSS3 as well.

Case studies

Our success stories

  • Hotels.com

    Hotels.com gained a much stronger competitive advantage due to a great mobile strategy

  • Macmillan

    Macmillan got fantastic results from our work, including a 50% reduction in mobile homepage drop-offs

  • Hitachi Capital

    Hitachi Capital now delivers a market-leading online proposition and the best user experience possible

More case studies

Training academy

View training courses

About us

We're a user experience agency (UX agency) that creates people-centred, efficient and delightful digital experiences.

Get in touch on 020 7423 6320