Calling Prototype methods in Javascript

Sometimes when one is working with jquery plugins, one desires to call a juicy method in the control.  And you know the method is there because you can see it in action.  But you can’t call it…  Because it’s in the prototype…

This very thing happened to me today using a plugin called Chosen.  Chosen is an extension of the drop down list which allows the user to filter the list of items.  Pretty cool idea, and it doesn’t look bad either.  The problem occurred with switching between chosen controls with the tab key.   When tab is pressed, the value of the first control is set and the “changed” event is fired.  In the change event, an ajax call is made to populate the values in the second control (based on the value of the first control).  The problem was I could never set focus to the second control once the populate was finished.  What I finally had to do was call the close and activate prototype methods like so:


Online XSLT testing tool

I’ve been loving the W3C Try It Editor for quite some time now.  It’s fantastic to try out javascript (why just last week I needed to see if you could append an array to an array with the “push” command – you can) or as I have recently discovered you can test out XSLT transforms.  However, it appears that the W3C editor only supports XSLT 1.0.  I needed to try an XLST 2.0 transformation, so after some searching I’ve stumbled across my new favorite editor:

TableSorter plugin parsing control

If you need to force the column type for the tablesorter control, the documentation says to use metadata classes like so:

 <th class="{sorter: 'text'}">first name</th> 

This is a pain to try to do in an XSLT, so I found another way.  This is how you force column type during tablesort initialization:

		headers: {
			1: { sorter : 'text' }

The column position is zero based, so this is forcing the sorter for the second column.

For more information, see: