Linux

Linux Mint 5 Elyssa

I’ve been using Ubuntu for the past couple of years now, and have found it a perfectly viable alternative to Windows.  As I mentioned in my very first post, I’m not a Linux zealot taking a political stance.  It’s just a simple preference.  If I was a zealot I’d be using a distribution like Gentoo, Slackware, or Linux From Scatch.  One for the hard nuts, I just want something that works on my five year old laptop.  I’m too tight to upgrade, so that rules out Vista.  Now there’s an OS that drives Linux fundamentalism.

In an attempt to challenge my OS of choice, but still keeping within my Ubuntu comfort zone, I installed Linux Mint last week.  Once slated as just a friendly, sexier version of Ubuntu, it now seems to be gaining in popularity.

Mint: Desktop

I’m very impressed.  I installed the OS, development IDE (Eclipse based Aptana), Apache, PHP, MySQL, and had the development version of this site up and running within a couple of hours.  No messing around getting Flash, RealPlayer, and various audio/video codecs running.  Anything I did need to install was a simple apt-get away in the Ubuntu repositories.
Continue reading

JavaScript

jQuery UI Date Picker control issue with .Net

Aye, I do whitter on about jQuery.  It’s ace.  The newly released jQuery UI is pretty special too.  One of the many great widgets is the Date Picker control.

I build many .net applications that require date entry, so I implement the Date Picker control often.  Unfortunately, there is a problem when it is used on a field that is validated using a .Net validation control.  Upon clicking on a date, I get the following error:

length is null or not an object

This only occurs when using Internet Explorer.  Currently, my only solution is to edit the source code.  Locate the following code in jquery-ui.js or ui.datepicker.js:

inst.input.trigger('change')

Replace it with:

if (!$.browser.msie){inst.input.trigger('change')}

This prevents the change event firing in IE.

I wouldn’t normally advocate changing source code in this manner, as it makes future upgrades tedious.  Hopefully it will be addressed in a future release.

.Net, JavaScript

Using jQuery selectors to reference .Net controls

You place a control onto your page:

<asp:Content ID="Content1" ContentPlaceHolderID="Content" Runat="Server">
	<asp:TextBox Id="Firstname" Runat="Server" />
</asp:Content>

The output is rendered as:

<input name="ctl00$Content$FirstName" type="text" id="ctl00_Content_FirstName" />

In the example above, the disparity in the rendered id attribute occurs because the TextBox control has been placed within a Content control, as the Page object inherits a MasterPage.

So how can you robustly reference the control using client-side JavaScript, regardless where the control resides?  Using jQuery it’s fairly trivial:

var $firstname = $("[id$=FirstName]");

This little snippet makes use of the jQuery attributeEndsWith selector, as documented here.  Bare in mind that an array is returned, as any control with an id that ends in FirstName will be selected.

Codeigniter, PHP

Using the Zend framework Lucene library

I know, only a few articles in, so I don’t really need a site search function.  But you never know, I might actually keep writing (even if no-one is reading) and so I’ve been looking around for some solutions.

I’ve looked at a few, for example: Swish-e, and Sphider.  Nothing really float my boat, until I had a look at the Zend Framework.  It’s another MVC based PHP framework, though it looks a little heavier than CodeIgniter.  The documentation is not as good either, but it did have a Lucene library.
Continue reading

JavaScript

JavaScript event delegation

As I’ve mentioned previously I’m creating a dashboard to represent the components in the exchange that I work for.  Each component widget on the page has a number of events associated with it.  This has become less manageable, the more I add.  So I thought about using one delegate to handle all events, and pass on a component reference, and parameters to other functions.

A quick google led me to this article by Dan Webb.  Looks like a common technique.  Very useful article, though I needed to be able to pass parameters to the functions.  There may be a better to way to do this, but this is how I achieved it.
Continue reading