Category Archives: web development

Should I do Something Only Because Crockford Says So?

Crockford says: “Don’t do that, please stop doing it!?” It may be related to JavaScript, YUI, CSS or whatever. PPK recently posted about browser prefixes with the same intonation. OK, fine, it’s difficult to maintain, it’s ugly but my job is to make the site look as nice as possible.

I agree with Crokford that only with copy/paste now JavaScript has the reputation of badly standardized language with no programmers that understand it at all. It’s true, but however this maybe made JavaScript so popular, now all the libraries come with that abstraction in mind and this gap seems to be smaller.

In addition I’ll say that’s fine if Crockford or PPK say something like that, but the primary goal of every web developer is not to be in good relations with Crockford, but to satisfy clients! I’d like to repeat – clients!

jQuery Get the Id of the Current Element

Useful Tips

Sometimes is really useful not only to read the docs, but to be aware of what the community is writing. Although you get familiar with a library or framework, it happens sometimes to discover very very useful things in them, kind of snippets, that you’ve missed all the time.

In that sense, I’m going to talk about something really small as code in jQuery, but that is quite used. The id selector.

It just so happens that after you discover the selection of an attribute with .attr() method you start selecting even the ids with it.

$('element').attr('id');

Which of course works quite well, but there is a built-in method that has clearer syntax and … better performance – the id.

Think of something like that:

$('element').click(function() {
    alert($(this).attr('id'));
}

It can be replaced with:

$('element').click(function() {
    alert($(this).id);
}

It’s cool!

Protect Your Web Forms with Zend_Service_Akismet

Akismet

If you’re a typical WordPress blogger you have definitely heart of Akismet, tool that gives you a real spam protection, but what is really really cool is the possibility to integrate Akismet via Zend Framework.

It’s pretty simple. There’s a service by Zend_Service_Akismet, which helps you a lot when integrating the Akismet in your Zend app.

That’s for now, but I’ll be definitely writing more and more on the topic.

HTML5 Makes Mobile Browsing Fun

iPhone and Nexus One

Although iPhone is not a buzz word anymore, it returns on the stage with its probably main rival – the Google Nexus One. Now maybe everybody have seen one of these two devices and has played around with it. What makes really fun when browsing is the support of special keyboards

Where Did .com Came From on the Keyboard?

You’ve probably seen that sometimes on the virtual keyboard of the mobile there is a special “virtual” button that places the “.com” string directly when entering a web address. That’s really fancy! It helps a lot of the lazy fingered.

Help Us HTML5

What HTML5 is supposed to help is that it can tell the mobile device which keyboard to open. You’re probably familiar with the “input” element:

<input type="text"...

and here comes the surprise. HTML5 gives us more. You can use not only “text” and “password”, but also “number”, “url” and “email”. See the picture bellow:

That’s really great, isn’t it?

Modyfing Response Headers with Zend Framework

Response Headers

You’ve probably seen that you can track the server response headers with Firebug – a wonderful extension to Firefox.

But have you ever asked yourself how to change a response header with Zend Framework.

header()

Typically this is done with the built in PHP function header, where you can setup the header the page must return, but how to make it with Zend Framework?

It’s pretty simple of course, it’s Zend Framework in fact. To be more precise I’ll post a snippet:

$response = $this->getResponse();
$response->setHeader('content-type', 'application/x-javascript; charset=utf-8');
$response->sendResponse();